Crates.io | into-from |
lib.rs | into-from |
version | |
source | src |
created_at | 2024-12-12 08:55:14.350509 |
updated_at | 2024-12-12 09:04:11.267335 |
description | Rust macro for impl Into |
homepage | |
repository | https://github.com/cody-why/macro-into |
max_upload_size | |
id | 1481011 |
Cargo.toml error: | TOML parse error at line 17, column 1 | 17 | 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 |
Rust macro for auto impl Into<T> or From<T> for Struct
impl Into<Bar> for Foo
struct Foo {
field1: i32,
field3: String,
}
#[into(Foo)]
struct Bar {
field1: i32,
#[into_skip]
field2: String,
#[into(self.field3.to_string())]
field3: i32,
}
Auto generated code:
impl Into<Foo> for Bar {
fn into(self) -> Foo {
Foo {
field1: self.field1,
field3: self.field3.to_string(),
}
}
}
impl From<Bar> for Foo
struct Foo {
field1: i32,
field2: String,
}
#[from(Foo)]
struct Bar {
field1: i32,
#[from(source.field2.parse::<i32>().unwrap())]
field3: i32,
}
Auto generated code:
impl From<Foo> for Bar {
fn from(source: Foo) -> Self {
Bar {
field1: source.field1,
field3: source.field2.parse::<i32>().unwrap(),
}
}
}