mirror of
https://github.com/rust-lang/rust
synced 2024-11-05 20:45:15 +00:00
18 lines
517 B
Rust
18 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());
|
|
}
|