Skip to main content

newtype_tools/
lib.rs

1#![doc = include_str!("../README.md")]
2
3pub mod iter;
4
5pub use iter::IntoIter;
6pub use iter::Iter;
7pub use iter::Iterator;
8#[cfg(feature = "derive")]
9pub use newtype_tools_derive::Newtype;
10#[cfg(feature = "derive")]
11pub use newtype_tools_derive::newtype;
12
13/// `Newtype` trait defines the internal representation of a `newtype`.
14///
15/// This trait is automatically derived for all types annotated with `#[derive(Newtype)]`
16/// along with the `From<Self::Inner>` and `AsRef<Self::Inner>` traits to convert
17/// between the inner type and the newtype.
18pub trait Newtype: AsRef<Self::Inner> + From<Self::Inner> {
19    /// The inner type.
20    type Inner;
21}