Skip to content

A thread safe Vec-like structure that never implicitly reallocates.

License

Notifications You must be signed in to change notification settings

me-self/fixed_vec

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FixedVec

A thread safe Vec-like structure that never implicitly reallocates (is of a fixed size).

Purpose

I created FixedVec for NECS (my game object management crate) so that objects could be spawned while others get accessed. FixedVec functions similarly to the standard library's Vec, but never implicitly reallocates (if an element can't fit, it is returned). This (along with the use of atomic operations for the length) allows for a thread-safe and immutable push.

let vec = FixedVec::<&str>::new(2);
assert_eq!(Ok(()), vec.push("foo"));
assert_eq!(Some(&"foo"), vec.get(0));
assert_eq!(Ok(()), vec.push("bar"));
assert_eq!(Err("baz"), vec.push("baz"));

About

A thread safe Vec-like structure that never implicitly reallocates.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages