7 releases

Uses old Rust 2015

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

#335 in Data structures

Download history 1373/week @ 2023-11-19 1511/week @ 2023-11-26 1038/week @ 2023-12-03 715/week @ 2023-12-10 1449/week @ 2023-12-17 1362/week @ 2023-12-24 1108/week @ 2023-12-31 805/week @ 2024-01-07 1060/week @ 2024-01-14 1551/week @ 2024-01-21 1290/week @ 2024-01-28 1288/week @ 2024-02-04 1766/week @ 2024-02-11 1603/week @ 2024-02-18 1709/week @ 2024-02-25 1656/week @ 2024-03-03

6,918 downloads per month
Used in 2 crates (via rmodbus)

MIT license

35KB
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

Features