2015-05-03 17:12:39 -05:00
|
|
|
// Test traits
|
|
|
|
|
|
|
|
trait Foo {
|
|
|
|
fn bar(x: i32) -> Baz<U> {
|
|
|
|
Baz::new()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn baz(a: AAAAAAAAAAAAAAAAAAAAAA, b: BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB) -> RetType;
|
|
|
|
|
2017-06-11 23:01:41 -05:00
|
|
|
fn foo(
|
|
|
|
a: AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA, // Another comment
|
|
|
|
b: BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB,
|
|
|
|
) -> RetType; // Some comment
|
2015-05-03 17:12:39 -05:00
|
|
|
|
|
|
|
fn baz(&mut self) -> i32;
|
|
|
|
|
|
|
|
fn increment(&mut self, x: i32);
|
|
|
|
|
2017-06-11 23:01:41 -05:00
|
|
|
fn read(&mut self, x: BufReader<R> /* Used to be MemReader */)
|
|
|
|
where
|
|
|
|
R: Read;
|
2015-05-03 17:12:39 -05:00
|
|
|
}
|
2015-07-19 07:33:02 -05:00
|
|
|
|
|
|
|
pub trait WriteMessage {
|
|
|
|
fn write_message(&mut self, &FrontendMessage) -> io::Result<()>;
|
|
|
|
}
|
2015-07-24 12:54:38 -05:00
|
|
|
|
|
|
|
trait Runnable {
|
|
|
|
fn handler(self: &Runnable);
|
|
|
|
}
|
2015-10-21 15:21:14 -05:00
|
|
|
|
|
|
|
trait TraitWithExpr {
|
|
|
|
fn fn_with_expr(x: [i32; 1]);
|
|
|
|
}
|
2015-12-02 14:08:09 -06:00
|
|
|
|
|
|
|
trait Test {
|
|
|
|
fn read_struct<T, F>(&mut self, s_name: &str, len: usize, f: F) -> Result<T, Self::Error>
|
2017-06-11 23:01:41 -05:00
|
|
|
where
|
|
|
|
F: FnOnce(&mut Self) -> Result<T, Self::Error>;
|
2015-12-02 14:08:09 -06:00
|
|
|
}
|
2016-03-11 15:18:30 -06:00
|
|
|
|
|
|
|
trait T {}
|
2016-03-14 21:05:20 -05:00
|
|
|
|
|
|
|
trait Foo {
|
|
|
|
type Bar: Baz;
|
2017-07-27 16:27:34 -05:00
|
|
|
type Inner: Foo = Box<Foo>;
|
2016-03-14 21:05:20 -05:00
|
|
|
}
|
|
|
|
|
2016-03-15 15:08:12 -05:00
|
|
|
trait ConstCheck<T>: Foo
|
2017-06-11 23:01:41 -05:00
|
|
|
where
|
|
|
|
T: Baz,
|
2016-03-14 21:05:20 -05:00
|
|
|
{
|
|
|
|
const J: i32;
|
|
|
|
}
|
2016-03-15 15:08:12 -05:00
|
|
|
|
2017-06-11 23:01:41 -05:00
|
|
|
trait Tttttttttttttttttttttttttttttttttttttttttttttttttttttttttt<T>
|
|
|
|
where
|
2017-07-26 21:09:38 -05:00
|
|
|
T: Foo,
|
2017-06-11 23:01:41 -05:00
|
|
|
{
|
|
|
|
}
|
2016-03-15 15:08:12 -05:00
|
|
|
|
|
|
|
trait Ttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt<T>
|
2017-06-11 23:01:41 -05:00
|
|
|
where
|
2017-07-26 21:09:38 -05:00
|
|
|
T: Foo,
|
2016-03-15 15:08:12 -05:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2018-03-10 00:23:42 -06:00
|
|
|
trait FooBar<T>: Tttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt
|
2017-06-11 23:01:41 -05:00
|
|
|
where
|
|
|
|
J: Bar,
|
2016-03-15 15:08:12 -05:00
|
|
|
{
|
|
|
|
fn test();
|
|
|
|
}
|
|
|
|
|
|
|
|
trait WhereList<T, J>
|
2017-06-11 23:01:41 -05:00
|
|
|
where
|
|
|
|
T: Foo,
|
2017-07-26 21:09:38 -05:00
|
|
|
J: Bar,
|
2016-03-15 15:08:12 -05:00
|
|
|
{
|
|
|
|
}
|
2017-08-27 10:18:17 -05:00
|
|
|
|
|
|
|
trait X /* comment */ {}
|
|
|
|
trait Y // comment
|
|
|
|
{
|
|
|
|
}
|
2017-11-10 06:20:54 -06:00
|
|
|
|
|
|
|
// #2055
|
|
|
|
pub trait Foo:
|
|
|
|
// A and C
|
|
|
|
A + C
|
|
|
|
// and B
|
|
|
|
+ B
|
|
|
|
{}
|
2017-11-15 20:26:12 -06:00
|
|
|
|
|
|
|
// #2158
|
|
|
|
trait Foo {
|
|
|
|
type ItRev = <MergingUntypedTimeSeries<SliceSeries<SliceWindow>> as UntypedTimeSeries>::IterRev;
|
|
|
|
type IteRev =
|
|
|
|
<MergingUntypedTimeSeries<SliceSeries<SliceWindow>> as UntypedTimeSeries>::IterRev;
|
|
|
|
}
|
2017-12-14 22:47:32 -06:00
|
|
|
|
2018-01-01 22:50:43 -06:00
|
|
|
// #2331
|
|
|
|
trait MyTrait<
|
|
|
|
AAAAAAAAAAAAAAAAAAAA,
|
2018-01-01 22:52:19 -06:00
|
|
|
BBBBBBBBBBBBBBBBBBBB,
|
|
|
|
CCCCCCCCCCCCCCCCCCCC,
|
|
|
|
DDDDDDDDDDDDDDDDDDDD,
|
2018-03-09 23:29:01 -06:00
|
|
|
>
|
|
|
|
{
|
2018-01-01 22:50:43 -06:00
|
|
|
fn foo() {}
|
|
|
|
}
|
|
|
|
|
2017-12-14 22:47:32 -06:00
|
|
|
// Trait aliases
|
|
|
|
trait FooBar = Foo + Bar;
|
|
|
|
trait FooBar<A, B, C> = Foo + Bar;
|
2019-02-11 19:16:12 -06:00
|
|
|
pub trait FooBar = Foo + Bar;
|
|
|
|
pub trait FooBar<A, B, C> = Foo + Bar;
|
2017-12-14 22:47:32 -06:00
|
|
|
trait AAAAAAAAAAAAAAAAAA = BBBBBBBBBBBBBBBBBBB + CCCCCCCCCCCCCCCCCCCCCCCCCCCCC + DDDDDDDDDDDDDDDDDD;
|
2019-02-11 19:16:12 -06:00
|
|
|
pub trait AAAAAAAAAAAAAAAAAA =
|
|
|
|
BBBBBBBBBBBBBBBBBBB + CCCCCCCCCCCCCCCCCCCCCCCCCCCCC + DDDDDDDDDDDDDDDDDD;
|
2017-12-14 22:47:32 -06:00
|
|
|
trait AAAAAAAAAAAAAAAAAAA =
|
|
|
|
BBBBBBBBBBBBBBBBBBB + CCCCCCCCCCCCCCCCCCCCCCCCCCCCC + DDDDDDDDDDDDDDDDDD;
|
|
|
|
trait AAAAAAAAAAAAAAAAAA =
|
|
|
|
BBBBBBBBBBBBBBBBBBB + CCCCCCCCCCCCCCCCCCCCCCCCCCCCC + DDDDDDDDDDDDDDDDDDD;
|
|
|
|
trait AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA<A, B, C, D, E> =
|
|
|
|
FooBar;
|
|
|
|
trait AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA<
|
|
|
|
A,
|
|
|
|
B,
|
|
|
|
C,
|
|
|
|
D,
|
|
|
|
E,
|
|
|
|
> = FooBar;
|
2018-05-13 23:25:10 -05:00
|
|
|
#[rustfmt::skip]
|
2017-12-14 22:47:32 -06:00
|
|
|
trait FooBar = Foo
|
|
|
|
+ Bar;
|
2018-04-22 17:31:21 -05:00
|
|
|
|
|
|
|
// #2637
|
|
|
|
auto trait Example {}
|
2018-05-18 16:25:33 -05:00
|
|
|
pub auto trait PubExample {}
|
|
|
|
pub unsafe auto trait PubUnsafeExample {}
|
2018-09-19 08:20:42 -05:00
|
|
|
|
|
|
|
// #3006
|
|
|
|
trait Foo<'a> {
|
|
|
|
type Bar<'a>;
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> Foo<'a> for i32 {
|
|
|
|
type Bar<'a> = i32;
|
|
|
|
}
|
2018-10-14 07:43:35 -05:00
|
|
|
|
|
|
|
// #3092
|
|
|
|
pub mod test {
|
|
|
|
pub trait ATraitWithALooongName {}
|
|
|
|
pub trait ATrait:
|
|
|
|
ATraitWithALooongName
|
|
|
|
+ ATraitWithALooongName
|
|
|
|
+ ATraitWithALooongName
|
|
|
|
+ ATraitWithALooongName
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
2019-05-26 07:14:28 -05:00
|
|
|
|
|
|
|
// Trait aliases with where clauses.
|
|
|
|
trait A = where for<'b> &'b Self: Send;
|
|
|
|
|
|
|
|
trait B = where for<'b> &'b Self: Send + Clone + Copy + SomeTrait + AAAAAAAA + BBBBBBB + CCCCCCCCCC;
|
|
|
|
trait B =
|
|
|
|
where for<'b> &'b Self: Send + Clone + Copy + SomeTrait + AAAAAAAA + BBBBBBB + CCCCCCCCCCC;
|
|
|
|
trait B = where
|
|
|
|
for<'b> &'b Self:
|
|
|
|
Send + Clone + Copy + SomeTrait + AAAAAAAA + BBBBBBB + CCCCCCCCCCCCCCCCCCCCCCC;
|
|
|
|
trait B = where
|
|
|
|
for<'b> &'b Self: Send
|
|
|
|
+ Clone
|
|
|
|
+ Copy
|
|
|
|
+ SomeTrait
|
|
|
|
+ AAAAAAAA
|
|
|
|
+ BBBBBBB
|
|
|
|
+ CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC;
|
|
|
|
|
|
|
|
trait B = where
|
|
|
|
for<'b> &'b Self: Send
|
|
|
|
+ Clone
|
|
|
|
+ Copy
|
|
|
|
+ SomeTrait
|
|
|
|
+ AAAAAAAA
|
|
|
|
+ BBBBBBB
|
|
|
|
+ CCCCCCCCC
|
|
|
|
+ DDDDDDD
|
|
|
|
+ DDDDDDDD
|
|
|
|
+ DDDDDDDDD
|
|
|
|
+ EEEEEEE;
|
|
|
|
|
|
|
|
trait A<'a, 'b, 'c> = Debug<T> + Foo where for<'b> &'b Self: Send;
|
|
|
|
|
|
|
|
trait B<'a, 'b, 'c> = Debug<T> + Foo
|
|
|
|
where
|
|
|
|
for<'b> &'b Self: Send + Clone + Copy + SomeTrait + AAAAAAAA + BBBBBBB + CCCCCCCCC + DDDDDDD;
|
|
|
|
|
|
|
|
trait B<'a, 'b, 'c, T> = Debug<'a, T>
|
|
|
|
where
|
|
|
|
for<'b> &'b Self: Send
|
|
|
|
+ Clone
|
|
|
|
+ Copy
|
|
|
|
+ SomeTrait
|
|
|
|
+ AAAAAAAA
|
|
|
|
+ BBBBBBB
|
|
|
|
+ CCCCCCCCC
|
|
|
|
+ DDDDDDD
|
|
|
|
+ DDDDDDDD
|
|
|
|
+ DDDDDDDDD
|
|
|
|
+ EEEEEEE;
|
2021-08-20 15:33:38 -05:00
|
|
|
|
|
|
|
trait Visible {
|
|
|
|
const C: i32;
|
|
|
|
pub type T;
|
|
|
|
fn f();
|
|
|
|
fn g() {}
|
|
|
|
}
|