Docs.rs
  • push-while-ref-0.1.1
    • push-while-ref 0.1.1
    • Docs.rs crate page
    • MIT OR Apache-2.0
    • Links
    • Repository
    • crates.io
    • Source
    • Owners
    • soerenmeier
    • Dependencies
    • Versions
    • 56.25% of the crate is documented
  • Platform
    • i686-pc-windows-msvc
    • i686-unknown-linux-gnu
    • x86_64-apple-darwin
    • x86_64-pc-windows-msvc
    • x86_64-unknown-linux-gnu
  • Feature flags
  • docs.rs
    • About docs.rs
    • Badges
    • Builds
    • Metadata
    • Shorthand URLs
    • Download
    • Rustdoc JSON
    • Build queue
    • Privacy policy
  • Rust
    • Rust website
    • The Book
    • Standard Library API Reference
    • Rust by Example
    • The Cargo Guide
    • Clippy Documentation

Crate push_while_ref

push_while_ref0.1.1

  • All Items

Sections

  • Example pushing
  • Example inserting

Crate Items

  • Structs
  • Traits

Crates

  • push_while_ref

Crate push_while_ref

Source
Expand description

A crate to enable holding a reference while still being able to push.
This is possible if you have another lifetime just for storing data (here called Owner).

The data that is inserted needs to not move in memory, because if the container (Vec, HashMap…) needs to reallocate that would invalidate the reference. this is garantie is give by the trait StaticType.

§Example pushing

use push_while_ref::{VecOwner, VecChild};

let mut vec = VecOwner::new();
let mut vec = vec.child();
let v1 = vec.push(Box::new(10));
let v2 = vec.push(Box::new(20));
assert_eq!(*v1, 10);
assert_eq!(*v2, 20);

§Example inserting

use push_while_ref::{HashMapOwner, HashMapChild};

let mut map = HashMapOwner::new();
let mut map = map.child();
let v1 = map.insert("10", Box::new(10));
let v2 = map.insert("20", Box::new(20));
assert_eq!(*v1, 10);
assert_eq!(*v2, 20);

Structs§

HashMapChild
HashMapOwner
VecChild
VecOwner

Traits§

StaticType
A value that is fixed in memory.

Results

Settings
Help

Query parser error: "Unexpected - (did you mean ->?)".