2018-10-12 01:50:03 +01:00
|
|
|
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
|
|
|
|
// file at the top-level directory of this distribution and at
|
|
|
|
// http://rust-lang.org/COPYRIGHT.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
|
|
|
|
|
|
|
#![feature(trait_alias)]
|
|
|
|
|
2018-10-22 01:58:34 +01:00
|
|
|
trait Foo = PartialEq<i32> + Send;
|
|
|
|
trait Bar = Foo + Sync;
|
2018-10-12 01:50:03 +01:00
|
|
|
|
2018-10-25 01:03:25 +01:00
|
|
|
trait I32Iterator = Iterator<Item = i32>;
|
|
|
|
|
2018-10-12 01:50:03 +01:00
|
|
|
pub fn main() {
|
2018-10-25 01:03:25 +01:00
|
|
|
let a: &dyn Bar = &123;
|
2018-10-22 01:58:34 +01:00
|
|
|
assert!(*a == 123);
|
|
|
|
let b = Box::new(456) as Box<dyn Foo>;
|
|
|
|
assert!(*b == 456);
|
2018-10-25 01:03:25 +01:00
|
|
|
|
2018-11-04 04:47:10 +00:00
|
|
|
let c: &mut dyn I32Iterator<Item = u32> = &mut vec![123].into_iter();
|
|
|
|
assert_eq!(c.next(), Some(123));
|
2018-10-12 01:50:03 +01:00
|
|
|
}
|