into_inner_derive
Procedural macro for automatically implementing the IntoInner trait (from the into_inner crate) for tuple structs with a single field.
Overview
into_inner_derive provides the #[derive(IntoInner)] procedural macro, which generates an implementation of the IntoInner trait (from the into_inner crate) for tuple structs with exactly one field. This allows you to easily extract the inner value from wrapper types without writing boilerplate code.
Note:
You should not use this crate directly. Instead, use the macro re-exported by the maininto_innercrate:use IntoInner; ;
Usage
Add the main crate to your Cargo.toml:
[]
= "0.1"
Then, in your code:
use IntoInner;
;
let wrapper = MyWrapper;
let inner = wrapper.into_inner;
assert_eq!;
Limitations
- The macro only works for tuple structs with exactly one field.
- Using the macro on structs with named fields or multiple fields will result in a compile-time error.
- The
IntoInnertrait must be in scope when using the macro.
Example: Compile-Time Error
use IntoInner;
; // Error: only tuple structs with one field are supported
License
Licensed under either of Apache License, Version 2.0 or MIT license at your option.
Contribution
Contributions are welcome! Please open issues or pull requests on GitLab.
See Also
- into_inner — the main crate re-exporting the trait and macro.