Some ideas for future development:
Add optional alias = "method_name" argument to create an alias for a conversion implementation:
#[newtype(into(Oranges, alias = "into_oranges" with = "..."))]
struct Apples(u64);
let apple = Apples(1);
let oranges = apple.into_oranges();Similar to the convenient aliases above, but instead of a method name, a base type is specified:
#[newtype(
base = "NumBytes",
from(NumBytes, with = "...")
)]
struct NumOsPages(u64);
#[newtype(
base = "NumBytes",
from(NumBytes, with = "...")
)]
struct NumWasmPages(u64);
let num_os_pages = NumOsPages(1);
let num_wasm_pages = num_os_pages.into();Something like:
#[newtype(Array)]
struct Apples([u64; 2]);
#[newtype(Vec)]
struct Oranges(Vec<u64>);It's not quite clear what it should derive by default:
Index-- make sense as a custom derive, i.e.#newtype(index(...))FromIterator?Extend?
There is no clear use case at the moment.
Consider a use case of extending functionality. See the extend crate:
https://crates.io/crates/extend