refmove

Crates.iorefmove
lib.rsrefmove
version0.1.3
sourcesrc
created_at2018-08-05 08:07:33.52821
updated_at2018-11-17 02:52:01.214509
descriptionAn experimental implementation of library-level by-move references
homepage
repositoryhttps://github.com/qnighy/rust-refmove
max_upload_size
id77596
size25,662
Masaki Hara (qnighy)

documentation

README

refmove: an experimental implementation of library-level by-move references

Build Status Latest Version

This crate contains an experimental implementation of library-level by-move references.

It will enable you to use self: RefMove<Self> to pass your trait object by value, even without allocation.

See #48055 for another approach to allow by-value trait objects.

Usage

Borrowing

#![feature(nll)]
extern crate refmove;
use refmove::{Anchor, AnchorExt, RefMove};

...

// Borrowing from stack
let _: RefMove<i32> = 42.anchor().borrow_move();

// Borrowing from box
let _: RefMove<i32> = Box::new(42).anchor_box().borrow_move();

Extracting

#![feature(nll)]
extern crate refmove;
use refmove::{Anchor, AnchorExt, RefMove};

...

fn f(x: RefMove<String>) {
    // Borrowing by dereference
    println!("{}", &x as &String);

    // Move out ownership
    let _: String = x.into_inner();
}
Commit count: 24

cargo fmt