refmove 0.1.2

An experimental implementation of library-level by-move references
docs.rs failed to build refmove-0.1.2
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Visit the last successful build: refmove-0.1.3

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.

When #50173 and #53033 land in the compiler, 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();
}