Last active
July 10, 2017 00:14
-
-
Save arrdem/09898e41fde567e30bf1faa8a851dcaa to your computer and use it in GitHub Desktop.
This file contains hidden or 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
struct MyVec<T>(T); | |
impl fmt::Display for MyVec<&Vec<i32>> { | |
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | |
write!(f, "["); | |
for (i, el) in *(self.0).iter().enumerate() { | |
if i != 0 { | |
write!(f, ", "); | |
} | |
write!(f, "{}", el); | |
} | |
write!(f, "]") | |
} | |
} | |
fn main() { | |
let mut vec = vec![1, 2, 3]; | |
{ | |
let _vec = MyVec(&vec); | |
println!("{}", _vec); | |
} | |
vec.push(4); | |
{ | |
let _vec = MyVec(&vec); | |
println!("{}", _vec); | |
} | |
} |
This file contains hidden or 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
-*- mode: cargo-process; default-directory: "~/scratch/" -*- | |
Cargo-Process started at Sun Jul 9 16:58:47 | |
cargo bench | |
Compiling scratch v0.1.0 (file:///home/arrdem/scratch) | |
error[E0106]: missing lifetime specifier | |
--> src/main.rs:39:29 | |
| | |
39 | impl fmt::Display for MyVec<&Vec<i32>> { | |
| ^ expected lifetime parameter | |
error: aborting due to previous error | |
error: Could not compile `scratch`. | |
To learn more, run the command again with --verbose. | |
Cargo-Process exited abnormally with code 101 at Sun Jul 9 16:58:47 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment