mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-05 05:04:24 +00:00
19 lines
516 B
Rust
19 lines
516 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());
|
|
}
|