6 releases

0.1.5 Jul 15, 2022
0.1.4 Jun 26, 2022
0.1.2 May 26, 2022

#1232 in Development tools

Download history 67/week @ 2022-11-28 110/week @ 2022-12-05 152/week @ 2022-12-12 669/week @ 2022-12-19 435/week @ 2022-12-26 58/week @ 2023-01-02 281/week @ 2023-01-09 726/week @ 2023-01-16 530/week @ 2023-01-23 576/week @ 2023-01-30 585/week @ 2023-02-06 225/week @ 2023-02-13 1115/week @ 2023-02-20 387/week @ 2023-02-27 259/week @ 2023-03-06 1462/week @ 2023-03-13

3,306 downloads per month
Used in 60 crates (2 directly)

MIT license

1MB
34K SLoC

Module :: derive_tools

experimental rust-status docs.rs Open in Gitpod discord

Collection of derives which extend STD.

Sample

#[ cfg( all( feature = "derive_from", feature = "derive_into", feature = "derive_display", feature = "derive_from_str" ) ) ]
{
  use derive_tools::*;

  #[ derive( From, Into, Display, FromStr, PartialEq, Debug ) ]
  #[ display( "{a}-{b}" ) ]
  struct Struct1
  {
    a : i32,
    b : i32,
  }

  // derived Into
  let src = Struct1 { a : 1, b : 3 };
  let got : ( i32, i32 ) = src.into();
  let exp = ( 1, 3 );
  assert_eq!( got, exp );

  // derived Display
  let src = Struct1 { a : 1, b : 3 };
  let got = format!( "{}", src );
  let exp = "1-3";
  println!( "{}", got );
  assert_eq!( got, exp );

  // derived FromStr
  use std::str::FromStr;
  let src = Struct1::from_str( "1-3" );
  let exp = Ok( Struct1 { a : 1, b : 3 } );
  assert_eq!( src, exp );
}

To add to your project

cargo add derive_tools

Try out from the repository

git clone https://github.com/Wandalen/wTools
cd wTools
cd sample/rust/derive_tools_trivial
cargo run

Dependencies

~0.6–1.7MB
~43K SLoC