Crates.io | derive_tools |
lib.rs | derive_tools |
version | |
source | src |
created_at | 2022-05-03 21:23:37.157911+00 |
updated_at | 2025-04-22 21:26:03.094302+00 |
description | A collection of derive macros designed to enhance STD. |
homepage | https://github.com/Wandalen/wTools/tree/master/module/core/derive_tools |
repository | https://github.com/Wandalen/wTools/tree/master/module/core/derive_tools |
max_upload_size | |
id | 580021 |
Cargo.toml error: | TOML parse error at line 21, column 1 | 21 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
derive_tools
# #[ cfg( all( feature = "derive_from", feature = "derive_inner_from", feature = "derive_display", feature = "derive_from_str" ) ) ]
{
use derive_tools::*;
#[ derive( From, InnerFrom, Display, FromStr, PartialEq, Debug ) ]
#[ display( "{a}-{b}" ) ]
struct Struct1
{
a : i32,
b : i32,
}
// derived InnerFrom
let src = Struct1 { a : 1, b : 3 };
let got : ( i32, i32 ) = src.into();
let exp = ( 1, 3 );
assert_eq!( got, exp );
// derived From
let src : Struct1 = ( 1, 3 ).into();
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 );
}
cargo add derive_tools
git clone https://github.com/Wandalen/wTools
cd wTools
cd examples/derive_tools_trivial
cargo run