7 releases

0.2.4 Jul 19, 2019
0.2.3 Aug 30, 2016
0.2.2 May 27, 2016
0.2.0 Dec 7, 2015
0.1.0 Sep 10, 2015

#36 in No standard library

Download history 320/week @ 2019-10-13 162/week @ 2019-10-20 347/week @ 2019-10-27 215/week @ 2019-11-03 217/week @ 2019-11-10 508/week @ 2019-11-17 348/week @ 2019-11-24 1103/week @ 2019-12-01 1203/week @ 2019-12-08 276/week @ 2019-12-15 197/week @ 2019-12-22 243/week @ 2019-12-29 286/week @ 2020-01-05 390/week @ 2020-01-12 430/week @ 2020-01-19

1,839 downloads per month
Used in 2 crates (via bootloader)

MIT license

34KB
383 lines

fixedvec

Build Status Version License

fixedvec is a Rust library/crate providing a heapless version of the Rust vector type. Although more limited than the libstd version, fixedvec provides a much-needed "managed" array type for embedded systems or other projects that cannot rely on the heap.

Install/Use

fixedvec is tested against the current stable, beta, and nightly, as well as the previous two stable Rust releases.

The #![no_std] attribute is available in stable Rust, but building binaries without libstd still requires the nightly compiler.

To use fixedvec, add the following to your Cargo.toml:

[dependencies]
fixedvec = "*"

Then add the following to your crate root:

#[macro_use] extern crate fixedvec;

Example

Buffering and mutating a list of bytes:

#[macro_use] extern crate fixedvec;

use fixedvec::FixedVec;

fn main() {
    let mut preallocated_space = alloc_stack!([u8; 10]);
    let mut vec = FixedVec::new(&mut preallocated_space);
    assert_eq!(vec.len(), 0);

    vec.push_all(&[1, 2, 3]).unwrap();
    assert_eq!(vec.len(), 3);
    assert_eq!(vec.as_slice(), &[1, 2, 3]);

    vec.map_in_place(|x: &mut u8| { *x *= 2 });
    assert_eq!(vec.as_slice(), &[2, 4, 6]);
}

License

Copyright (c) 2015-2016, Nick Stevens <nick@bitcurry.com>

The MIT License (MIT)

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

No runtime deps