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
380 B
Rust
Raw Normal View History

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