into_inner

Crates.iointo_inner
lib.rsinto_inner
version0.1.2
created_at2025-05-16 10:12:29.867819+00
updated_at2025-06-03 13:27:07.236417+00
descriptionIntoInner trait for Rust newtypes
homepage
repositoryhttps://gitlab.com/max.martinelli/into_inner
max_upload_size
id1676314
size14,140
Massimiliano Martinelli (max-1975)

documentation

https://docs.rs/into_inner_derive/latest/into_inner/

README

into_inner

Crates.io Docs.rs

A simple trait and derive macro for extracting the inner value from tuple structs (newtypes) with a single field.


Overview

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.


Usage

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!");

Features

  • Derive macro for tuple structs with a single field.
  • Compile-time errors for unsupported struct types.
  • No dependencies outside of proc-macro ecosystem.

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

Commit count: 11

cargo fmt