trapper

Crates.iotrapper
lib.rstrapper
version2.0.0
sourcesrc
created_at2019-07-30 09:23:42.574955
updated_at2019-08-01 00:28:02.615313
descriptionA library for creating newtypes that don't require ownership of their internal value
homepage
repositoryhttps://github.com/ObsidianMinor/trapper
max_upload_size
id152869
size5,820
(ObsidianMinor)

documentation

README

trapper

A simple Rust library for creating transparent newtypes that don't require ownership to be used.

Example

use trapper::{Wrapper, newtype};
newtype!(#[derive(PartialEq, Debug)] type NumberWrapper(i32));

fn foo(r: &i32, m: &mut i32) {
    let ref_wrapper: &NumberWrapper = NumberWrapper::wrap_ref(r);
    let mut_wrapper: &mut NumberWrapper = NumberWrapper::wrap_mut(m);
}

let mut wrapper = NumberWrapper::wrap(12);
*wrapper.unwrap_mut() = 13;

assert_eq!(wrapper, NumberWrapper::wrap(13));
Commit count: 5

cargo fmt