Skip to content

Allows you to use the impl macro from the rust source over your own array.

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE-2
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

derekdreery/newtype_array-rs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This crate has a single macro, newtype_arrays, that will create transparent newtypes for arrays, and implement standard traits for them. It will be redundant when generic cosntants land, in the mean time it means you can use large arrays on stable rust.

Examples

#[macro_use]
extern crate newtype_array;

use std::collections::HashMap;

// Sha385 length
newtype_array!(pub struct Array48(pub 48));
// Sha512 length
newtype_array!(pub struct Array64(pub 64));

// We've got `Clone` and `PartialEq`/`Eq`
let arr1 = Array48([0u8; 48]);
let arr2 = arr1.clone();
assert_eq!(arr1, arr2);

// `Hash` is implemented as well
let mut map = HashMap::new();
map.insert(arr1, "hello");

About

Allows you to use the impl macro from the rust source over your own array.

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE-2
MIT
LICENSE-MIT

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages