1 unstable release

Uses old Rust 2015

0.0.1 Apr 29, 2016

#4 in #tmp

CC0 license

4KB

Problem:

pub struct Foo {
    ...
}

impl Foo {
    fn do_something(&mut self, ...){
        //FIXME: avoid allocation. can't fix this because T is lifetime-bound.
        let mut guards: Vec<Guard<'x>> = Vec::with_capacity(xxx.len());
        ...
    }
}

Solution:

use tmp_vec::TmpVec;

pub struct Foo {
    tmp_guards: TmpVec<Guard<'static>>,
    ...
}

impl Foo {
    fn do_something(&mut self, ...){
         let mut guards = self.tmp_guards.borrow_mut();
         ...
    }
}
        

lib.rs:

Problem:

pub struct Foo {
    ...
}

impl Foo {
    fn do_something(&mut self, ...){
        //FIXME: avoid allocation. can't fix this because T is lifetime-bound.
        let mut guards: Vec<Guard<'x>> = Vec::with_capacity(xxx.len());
        ...
    }
}

Solution:

use tmp_vec::TmpVec;

pub struct Foo {
    tmp_guards: TmpVec<Guard<'static>>,
    ...
}

impl Foo {
    fn do_something(&mut self, ...){
         let mut guards = self.tmp_guards.borrow_mut();
         ...
    }
}
        

No runtime deps