Crates.io | validated-slice |
lib.rs | validated-slice |
version | 0.2.0 |
source | src |
created_at | 2019-09-25 16:02:40.438549 |
updated_at | 2019-10-25 14:29:45.548449 |
description | Helper macros to implement std traits for custom validated slice types |
homepage | |
repository | https://github.com/lo48576/validated-slice |
max_upload_size | |
id | 167577 |
size | 182,631 |
Helper macros to implement std traits for custom validated slice types in Rust.
See tests/ascii_str.rs
and tests/plain_str.rs
for
example.
These examples defines custom string types and implement basic std traits for them by this crate.
To define opaque type aliases for data with specific characteristics, you may want to define custom slice types and vector types. For example:
PartialEq
and PartialOrd
).However, primitive types [T]
and str
have many trait impls, and custom array types might be non-user-friendly without such trait impls.
(For example, if you want ASCII string &AsciiStr
, you may also want Default for &AsciiStr
, std::convert::TryFrom<&str> for &AsciiStr
, PartialEq<str> for &AsciiStr
, PartialOrd<AsciiStr> for Cow<'_, AsciiStr>
, std::fmt::Display for
AsciiStr`, etc.)
validated-slice
helps users to automatically implement these traits common for array and string with less boilerplates.
This crate is at an early stage, and experimental. Breaking changes would be introduced for syntax and features.
This crate follows semver, so you can check crate version to know breaking change.
For desired features without detailed ideas, see TODO.md.
Licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.