diff --git a/Cargo.lock b/Cargo.lock index 91a992c..b1a7896 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -489,7 +489,7 @@ dependencies = [ ] [[package]] -name = "typer" +name = "typed" version = "0.1.0" dependencies = [ "proc-macro2", diff --git a/Cargo.toml b/Cargo.toml index 85797d2..1108bdc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "typer" +name = "typed" version = "0.1.0" edition = "2021" description = "Get the types of a struct" diff --git a/README.md b/README.md index b35af6c..886f85d 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,34 @@ trait Trait: Container::protocol { fn extend(&mut self, val: Container::protocol::another); } ``` +### More +````rust +#[type_it] +struct Container { + a: i32, + b: Vec, + c: Vec, + d: C, + e: T +} + +#[type_it] +struct Tuple(i32, i32); + +#[type_it] +struct Tuple2(i32, T); + +fn main() { + let a: Container::fields::a = 10; + let b: Container::b = vec![a]; + let c: Container::c = vec![10]; + let c: as Container::protocol>::c = c; + let d: as Container::protocol>::d = 10; + let container: Container::core = Container::core { a, b, c, d, e: 10 }; + + assert!(container.a == a); +} +```` # Disassembler ```rust diff --git a/tests/typed-test.rs b/tests/typed-test.rs index 76fc890..2353cf5 100644 --- a/tests/typed-test.rs +++ b/tests/typed-test.rs @@ -1,7 +1,7 @@ #![allow(unused_variables)] -extern crate typer; -use typer::type_it; +extern crate typed; +use typed::type_it; #[type_it] struct Container { @@ -21,7 +21,8 @@ struct Tuple2(i32, T); fn main() { let a: Container::fields::a = 10; let b: Container::b = vec![a]; - let c: as Container::protocol>::c = vec![10]; + let c: Container::c = vec![10]; + let c: as Container::protocol>::c = c; let d: as Container::protocol>::d = 10; let container: Container::core = Container::core { a, b, c, d, e: 10 };