2017-11-14 08:37:27 -06:00
|
|
|
// rustfmt-spaces_within_parens_and_brackets: true
|
|
|
|
// Spaces within parens and brackets
|
|
|
|
|
|
|
|
fn lorem< T: Eq >( t: T ) {
|
|
|
|
let lorem = ( ipsum, dolor );
|
|
|
|
let lorem: [ usize; 2 ] = [ ipsum, dolor ];
|
|
|
|
}
|
|
|
|
|
|
|
|
enum E {
|
|
|
|
A( u32 ),
|
|
|
|
B( u32, u32 ),
|
|
|
|
C( u32, u32, u32 ),
|
|
|
|
D(),
|
|
|
|
}
|
|
|
|
|
|
|
|
struct TupleStruct0();
|
|
|
|
struct TupleStruct1( u32 );
|
|
|
|
struct TupleStruct2( u32, u32 );
|
|
|
|
|
|
|
|
fn fooEmpty() {}
|
|
|
|
|
|
|
|
fn foo( e: E, _: u32 ) -> ( u32, u32 ) {
|
|
|
|
// Tuples
|
|
|
|
let t1 = ();
|
|
|
|
let t2 = ( 1, );
|
|
|
|
let t3 = ( 1, 2 );
|
|
|
|
|
|
|
|
let ts0 = TupleStruct0();
|
|
|
|
let ts1 = TupleStruct1( 1 );
|
|
|
|
let ts2 = TupleStruct2( 1, 2 );
|
|
|
|
|
|
|
|
// Tuple pattern
|
|
|
|
let ( a, b, c ) = ( 1, 2, 3 );
|
|
|
|
|
|
|
|
// Expressions
|
|
|
|
let x = ( 1 + 2 ) * ( 3 );
|
|
|
|
|
|
|
|
// Function call
|
|
|
|
fooEmpty();
|
|
|
|
foo( 1, 2 );
|
|
|
|
|
|
|
|
// Pattern matching
|
|
|
|
match e {
|
|
|
|
A( _ ) => (),
|
|
|
|
B( _, _ ) => (),
|
|
|
|
C( .. ) => (),
|
|
|
|
D => (),
|
|
|
|
}
|
|
|
|
|
|
|
|
( 1, 2 )
|
|
|
|
}
|
|
|
|
|
|
|
|
struct Foo< T > {
|
|
|
|
i: T,
|
|
|
|
}
|
|
|
|
|
|
|
|
struct Bar< T, E > {
|
|
|
|
i: T,
|
|
|
|
e: E,
|
|
|
|
}
|
|
|
|
|
|
|
|
struct Foo< 'a > {
|
|
|
|
i: &'a str,
|
|
|
|
}
|
|
|
|
|
|
|
|
enum E< T > {
|
2017-11-14 08:41:33 -06:00
|
|
|
T( T ),
|
2017-11-14 08:37:27 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
enum E< T, S > {
|
2017-11-14 08:41:33 -06:00
|
|
|
T( T ),
|
|
|
|
S( S ),
|
2017-11-14 08:37:27 -06:00
|
|
|
}
|
|
|
|
|
2017-11-14 08:41:33 -06:00
|
|
|
fn foo< T >( a: T ) {
|
|
|
|
foo::< u32 >( 10 );
|
2017-11-14 08:37:27 -06:00
|
|
|
}
|
|
|
|
|
2017-11-14 08:41:33 -06:00
|
|
|
fn foo< T, E >( a: T, b: E ) {
|
|
|
|
foo::< u32, str >( 10, "bar" );
|
2017-11-14 08:37:27 -06:00
|
|
|
}
|
|
|
|
|
2017-11-14 08:41:33 -06:00
|
|
|
fn foo< T: Send, E: Send >( a: T, b: E ) {
|
|
|
|
foo::< u32, str >( 10, "bar" );
|
2017-11-14 08:37:27 -06:00
|
|
|
|
|
|
|
let opt: Option< u32 >;
|
|
|
|
let res: Result< u32, String >;
|
|
|
|
}
|
|
|
|
|
2017-11-14 08:41:33 -06:00
|
|
|
fn foo< 'a >( a: &'a str ) {
|
|
|
|
foo( "foo" );
|
2017-11-14 08:37:27 -06:00
|
|
|
}
|
|
|
|
|
2017-11-14 08:41:33 -06:00
|
|
|
fn foo< 'a, 'b >( a: &'a str, b: &'b str ) {
|
|
|
|
foo( "foo", "bar" );
|
2017-11-14 08:37:27 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
impl Foo {
|
|
|
|
fn bar() {
|
|
|
|
< Foo as Foo >::bar();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
trait MyTrait< A, D > {}
|
|
|
|
impl< A: Send, D: Send > MyTrait< A, D > for Foo {}
|
|
|
|
|
|
|
|
fn foo()
|
2017-11-14 08:41:33 -06:00
|
|
|
where
|
2017-11-14 08:37:27 -06:00
|
|
|
for< 'a > u32: 'a,
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let arr: [ i32; 5 ] = [ 1, 2, 3, 4, 5 ];
|
|
|
|
let arr: [ i32; 500 ] = [ 0; 500 ];
|
|
|
|
|
|
|
|
let v = vec![ 1, 2, 3 ];
|
2017-11-14 08:41:33 -06:00
|
|
|
assert_eq!( arr, [ 1, 2, 3 ] );
|
2017-11-14 08:37:27 -06:00
|
|
|
|
|
|
|
let i = arr[ 0 ];
|
|
|
|
|
|
|
|
let slice = &arr[ 1..2 ];
|
|
|
|
|
|
|
|
let line100_________________________________________________________________________ = [ 1, 2 ];
|
|
|
|
let line101__________________________________________________________________________ =
|
|
|
|
[ 1, 2 ];
|
|
|
|
let line102___________________________________________________________________________ =
|
|
|
|
[ 1, 2 ];
|
|
|
|
let line103____________________________________________________________________________ =
|
|
|
|
[ 1, 2 ];
|
|
|
|
let line104_____________________________________________________________________________ =
|
|
|
|
[ 1, 2 ];
|
|
|
|
|
|
|
|
let line100_____________________________________________________________________ = vec![ 1, 2 ];
|
|
|
|
let line101______________________________________________________________________ =
|
|
|
|
vec![ 1, 2 ];
|
|
|
|
let line102_______________________________________________________________________ =
|
|
|
|
vec![ 1, 2 ];
|
|
|
|
let line103________________________________________________________________________ =
|
|
|
|
vec![ 1, 2 ];
|
|
|
|
let line104_________________________________________________________________________ =
|
|
|
|
vec![ 1, 2 ];
|
|
|
|
}
|
|
|
|
|
2017-11-14 08:41:33 -06:00
|
|
|
fn f( slice: &[ i32 ] ) {}
|