Skip to content

Instantly share code, notes, and snippets.

@rust-play
Created November 26, 2018 12:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rust-play/91ad3ea6ef3c07e8b0b3a8c6301af600 to your computer and use it in GitHub Desktop.
Save rust-play/91ad3ea6ef3c07e8b0b3a8c6301af600 to your computer and use it in GitHub Desktop.
Code shared from the Rust Playground
#![feature(nll)]
use std::cell::Cell;
trait Thing: Sized {
fn do_the_thing(&mut self, s: i32) {}
}
impl<T> Thing for Cell<T> {}
fn main() {
use std::ops::AddAssign;
let mut x = Cell::new(1);
let l = &x;
x // (1)
.do_the_thing(
{
x.set(3);
l.set(4);
x.get() // (2)
+
l.get() // (4)
}
) // (3)
;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment