mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-27 17:24:06 +00:00
40ae34194c
detects redundant imports that can be eliminated. for #117772 : In order to facilitate review and modification, split the checking code and removing redundant imports code into two PR.
26 lines
406 B
Rust
26 lines
406 B
Rust
// run-pass
|
|
|
|
struct StringBuffer {
|
|
s: String,
|
|
}
|
|
|
|
impl StringBuffer {
|
|
pub fn append(&mut self, v: &str) {
|
|
self.s.push_str(v);
|
|
}
|
|
}
|
|
|
|
fn to_string(sb: StringBuffer) -> String {
|
|
sb.s
|
|
}
|
|
|
|
pub fn main() {
|
|
let mut sb = StringBuffer {
|
|
s: String::new(),
|
|
};
|
|
sb.append("Hello, ");
|
|
sb.append("World!");
|
|
let str = to_string(sb);
|
|
assert_eq!(str, "Hello, World!");
|
|
}
|