Created
November 26, 2018 12:39
-
-
Save rust-play/91ad3ea6ef3c07e8b0b3a8c6301af600 to your computer and use it in GitHub Desktop.
Code shared from the Rust Playground
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#![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