2017-06-23 00:27:47 +03:00
|
|
|
pub trait Mirror<Smoke> {
|
|
|
|
type Image;
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<T, Smoke> Mirror<Smoke> for T {
|
|
|
|
type Image = T;
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn poison<S>(victim: String) where <String as Mirror<S>>::Image: Copy {
|
2018-05-06 22:57:49 +01:00
|
|
|
loop { drop(victim); }
|
2017-06-23 00:27:47 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let s = "Hello!".to_owned();
|
|
|
|
let mut s_copy = s;
|
|
|
|
s_copy.push_str("World!");
|
|
|
|
"0wned!".to_owned();
|
2019-04-22 08:40:08 +01:00
|
|
|
println!("{}", s); //~ ERROR borrow of moved value
|
2017-06-23 00:27:47 +03:00
|
|
|
}
|