# into_inner_derive
[](https://crates.io/crates/into_inner_derive)
[](https://docs.rs/into_inner_derive)
Procedural macro for automatically implementing the `IntoInner` trait (from the [`into_inner`](https://crates.io/crates/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`](https://crates.io/crates/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 main [`into_inner`](https://crates.io/crates/into_inner) crate:
>
> ```rust
> use into_inner::IntoInner;
>
> #[derive(IntoInner)]
> struct MyWrapper(String);
> ```
---
## Usage
Add the main crate to your `Cargo.toml`:
```toml
[dependencies]
into_inner = "0.1"
```
Then, in your code:
```rust
use into_inner::IntoInner;
#[derive(IntoInner)]
struct MyWrapper(String);
let wrapper = MyWrapper("Hello, world!".to_string());
let inner = wrapper.into_inner();
assert_eq!(inner, "Hello, world!");
```
---
## 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 `IntoInner` trait must be in scope when using the macro.
---
## Example: Compile-Time Error
```rust,compile_fail
use into_inner::IntoInner;
#[derive(IntoInner)]
struct InvalidWrapper(String, i32); // Error: only tuple structs with one field are supported
```
---
## License
Licensed under either of [Apache License, Version 2.0](LICENSE-APACHE) or [MIT license](LICENSE-MIT) at your option.
---
## Contribution
Contributions are welcome! Please open issues or pull requests on [GitLab](https://gitlab.com/max.martinelli/into_inner).
---
## See Also
- [into_inner](https://crates.io/crates/into_inner) — the main crate re-exporting the trait and macro.