Crates.io | into_inner |
lib.rs | into_inner |
version | 0.1.2 |
created_at | 2025-05-16 10:12:29.867819+00 |
updated_at | 2025-06-03 13:27:07.236417+00 |
description | IntoInner trait for Rust newtypes |
homepage | |
repository | https://gitlab.com/max.martinelli/into_inner |
max_upload_size | |
id | 1676314 |
size | 14,140 |
A simple trait and derive macro for extracting the inner value from tuple structs (newtypes) with a single field.
The into_inner
crate provides the IntoInner
trait and a convenient #[derive(IntoInner)]
macro for tuple structs with exactly one field. This allows you to easily extract the wrapped value from your newtypes without boilerplate.
Add this to your Cargo.toml
:
[dependencies]
into_inner = "0.1"
Then, in your code:
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!");
Licensed under either of Apache License, Version 2.0 or MIT license at your option.
Contributions are welcome! Please open issues or pull requests on GitLab.