4 releases
Uses old Rust 2015
0.2.2 | Jul 30, 2018 |
---|---|
0.2.1 | Jul 30, 2018 |
0.2.0 |
|
0.1.1 | Jul 29, 2018 |
0.1.0 | Jul 29, 2018 |
#43 in #owned
30KB
649 lines
new_type_derive
This crate provides the new_type_pair!
macro, which allows for the creation of
a wrapping type over primitives and their references. For example, when creating
a strongly-typed wrapper for an identifier around a String
, we may also want
an accompanying strongly-typed wrapper around the reference type str
. This can
enable better zero-copy behavior while still keeping the benefits of a
strongly-typed wrapper.
The reference new type must implement the NewTypeRef
trait, which provides a
mechanism for validating that the value is valid before returning the wrapped
new type. It also ensures that you are able to seamlessly transition between the
reference type, the owned type, the underlying owned type, and the underlying
reference type through the automatic implementation of From
, AsRef
,
Borrow
, PartialEq
, and PartialOrd
, as well as Serialize
and
Deserialize
when the serde
feature is enabled.
lib.rs
:
This crate provides a means of easily creating a wrapper new type along with a corresponding reference type
Dependencies
~175KB