mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-27 17:24:06 +00:00
19 lines
517 B
Rust
19 lines
517 B
Rust
//@ run-pass
|
|
|
|
fn assert_repr_eq<T: std::fmt::Debug>(obj : T, expected : String) {
|
|
assert_eq!(expected, format!("{:?}", obj));
|
|
}
|
|
|
|
pub fn main() {
|
|
let abc = [1, 2, 3];
|
|
let tf = [true, false];
|
|
let x = [(), ()];
|
|
let slice = &x[..1];
|
|
|
|
assert_repr_eq(&abc[..], "[1, 2, 3]".to_string());
|
|
assert_repr_eq(&tf[..], "[true, false]".to_string());
|
|
assert_repr_eq(&x[..], "[(), ()]".to_string());
|
|
assert_repr_eq(slice, "[()]".to_string());
|
|
assert_repr_eq(&x[..], "[(), ()]".to_string());
|
|
}
|