typevec 0.1.0

Rust Vec which can contain arbitrary types
Documentation
  • Coverage
  • 5.26%
    1 out of 19 items documented0 out of 17 items with examples
  • Size
  • Source code size: 8.34 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 339.81 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 9s Average build duration of successful builds.
  • all releases: 9s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • sinhrks/rust-anycollections
    2 1 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • sinhrks

typevec

Rust Vec which can contain arbitrary types inrernally casts inputs to Box<UnsafeAny>.

let mut v = TypeVec::new();
assert!(v.is_empty());

// Can push whatever values.
v.push(1);
v.push(2.2);
v.push("xxx");
v.push(vec![1, 2, 3]);

// Give type hint to specify return type.
assert_eq!(v.get::<i32>(0), Some(&1));
assert_eq!(v.get::<f64>(1), Some(&2.2));
assert_eq!(v.get::<&str>(2), Some(&"xxx"));
assert_eq!(v.get::<Vec<i32>>(3), Some(&vec![1, 2, 3]));

// get_mut
assert_eq!(v.get_mut::<Vec<i32>>(3), Some(&mut vec![1, 2, 3]));

// pop
assert_eq!(v.pop::<Vec<i32>>(), Some(vec![1, 2, 3]));
assert_eq!(v.pop::<&str>(), Some("xxx"));
assert_eq!(v.pop::<f64>(), Some(2.2));
assert_eq!(v.pop::<i32>(), Some(1));