Function extendr_api::functions::new_env_with_capacity[][src]

pub fn new_env_with_capacity(capacity: usize) -> Robj

Create a new, empty environment parented on global_env() with a reserved size.

This function will guess the hash table size if required. Use the Env{} wrapper for more detail.

use extendr_api::prelude::*;
test! {
    let env = new_env_with_capacity(5);
    env.set_local(sym!(a), 1);
    env.set_local(sym!(b), 2);
    assert_eq!(env.len(), 2);
}