Crates.io | anythingy |
lib.rs | anythingy |
version | 0.1.2 |
source | src |
created_at | 2024-03-21 14:54:10.542925 |
updated_at | 2024-05-13 21:50:02.885304 |
description | A library for dynamic typing. |
homepage | |
repository | https://github.com/wutterfly/anythingy |
max_upload_size | |
id | 1181721 |
size | 43,195 |
This is a work-in-progess project and not for production use.
Thingy: a [..] thing whose name one has forgotten, does not know, or does not wish to mention. [from Oxford Languages]
A library for dynamic typing. It's main feature is the Thing type, that works similar to Box<dyn Any>, but can be sized at compile time while falling back to boxing the value, if it's too big.
use anything::Thing;
fn main() {
let number_thing: Thing<24> = Thing::new(42u64);
let string_thing: Thing<24> = Thing::new(String::from("Hello there"));
let bytes_thing: Thing<24> = Thing::new(Vec::from(b"so uncivilized"));
let number = number_thing.get::<u64>();
assert_eq!(number, 42);
let string = string_thing.get::<String>();
assert_eq!(&string, "Hello there");
let bytes = bytes_thing.get::<Vec<u8>>();
assert_eq!(&bytes, b"so uncivilized");
}
This project is licensed under the MIT license.