rust/tests/ui/traits/alias/object.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

19 lines
379 B
Rust
Raw Normal View History

2019-03-30 17:06:09 -05:00
// run-pass
#![feature(trait_alias)]
2018-10-21 19:58:34 -05:00
trait Foo = PartialEq<i32> + Send;
trait Bar = Foo + Sync;
2018-10-24 19:03:25 -05:00
trait I32Iterator = Iterator<Item = i32>;
pub fn main() {
2018-10-24 19:03:25 -05:00
let a: &dyn Bar = &123;
2018-10-21 19:58:34 -05:00
assert!(*a == 123);
let b = Box::new(456) as Box<dyn Foo>;
assert!(*b == 456);
2018-10-24 19:03:25 -05:00
let c: &mut dyn I32Iterator = &mut vec![123].into_iter();
2018-11-03 23:47:10 -05:00
assert_eq!(c.next(), Some(123));
}