rust/tests/target/trait.rs

133 lines
2.5 KiB
Rust
Raw Normal View History

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<()>;
}
trait Runnable {
fn handler(self: &Runnable);
}
trait TraitWithExpr {
fn fn_with_expr(x: [i32; 1]);
}
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>;
}
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
}
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;
}
2017-06-11 23:01:41 -05:00
trait Tttttttttttttttttttttttttttttttttttttttttttttttttttttttttt<T>
where
T: Foo,
2017-06-11 23:01:41 -05:00
{
}
trait Ttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt<T>
2017-06-11 23:01:41 -05:00
where
T: Foo,
{
}
trait FooBar<T>
: Tttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt
2017-06-11 23:01:41 -05:00
where
J: Bar,
{
fn test();
}
trait WhereList<T, J>
2017-06-11 23:01:41 -05:00
where
T: Foo,
J: Bar,
{
}
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
// #2331
trait MyTrait<
AAAAAAAAAAAAAAAAAAAA,
BBBBBBBBBBBBBBBBBBBB,
CCCCCCCCCCCCCCCCCCCC,
DDDDDDDDDDDDDDDDDDDD,
> {
fn foo() {}
}
2017-12-14 22:47:32 -06:00
// Trait aliases
trait FooBar = Foo + Bar;
trait FooBar<A, B, C> = Foo + Bar;
trait AAAAAAAAAAAAAAAAAA = BBBBBBBBBBBBBBBBBBB + CCCCCCCCCCCCCCCCCCCCCCCCCCCCC + DDDDDDDDDDDDDDDDDD;
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;
#[rustfmt_skip]
trait FooBar = Foo
+ Bar;