Warning, /frameworks/syntax-highlighting/autotests/input/test.rs is written in an unsupported language. File is not indexed.
0001 // Comment NOTE 0002 /* Comment FIXME ALERT 0003 */ 0004 0005 // Identifiers 0006 hellóñαωΑΩµo!(); 0007 HellóñαωΑΩµ::Hello; 0008 'hellóñαωΑΩµo 0009 0010 pub use self::PathParameters::*; 0011 pub use symbol::{Ident, Symbol as Name}; 0012 use serialize::{self, Encoder, Decoder}; 0013 use std::u32; 0014 0015 #[derive(Clone, PartialEq, Eq, Hash, Copy)] 0016 0017 pub struct Lifetime { 0018 pub id: NodeId, 0019 pub span: Span, 0020 pub bounds: Vec<PathSegment> 0021 } 0022 0023 impl fmt::Debug for Lifetime { 0024 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 0025 write!(f, "lifetime({}: {})", self.id, pprust::lifetime_to_string(self)) 0026 } 0027 } 0028 impl<'a> PartialEq<&'a str> for Path { 0029 fn eq(&self, string: &&'a str) -> bool { 0030 self.segments.len() == 1 && self.segments[0].identifier.name == *string 0031 } 0032 } 0033 0034 enum TraitBoundModifier { 0035 None, 0036 Maybe, 0037 } 0038 0039 union tests { 0040 a: i128, 0041 b: isize, 0042 } 0043 0044 // Self vs self 0045 trait T { 0046 type Item; 0047 // `Self` will be whatever type that implements `T`. 0048 fn new() -> Self; 0049 // `Self::Item` will be the type alias in the implementation. 0050 fn f(&self) -> Self::Item; 0051 } 0052 0053 // Raw identifiers 0054 extern crate foo; 0055 fn main() { 0056 foo::r#try(); 0057 } 0058 0059 #[valid types] 0060 fn types() { 0061 let num = 333_3_; 0062 let num_u8: u8 = 333u8; 0063 let num_u16: u16 = 333u16; 0064 let num_u32: u32 = 333u32; 0065 let num_u64: u64 = 333u64; 0066 let num_u128: u128 = 333u128; 0067 let num_usize: usize = 333usize; 0068 let num_float: f32 = 333.45f32; 0069 0070 let binary = 0b1_010; 0071 let octal = 0o21535; 0072 let hexadecimal = 0x73A2_F; 0073 0074 let char1: char = 'a'; 0075 let char2: char = '\n'; 0076 let char3: char = '\u{123_AF}'; 0077 0078 let byte1: u8 = b'a'; 0079 let byte2: u8 = b'\x13'; 0080 0081 let string: str = "hello \n \r \u{123_________fd_} \ 0082 bye"; 0083 let byte_string: str = b"hello \t \0 \u{123} \b bye"; 0084 let raw_string1: str = r"hello \t \b"; 0085 let raw_string2: str = r####"hello \n "### bye"########; 0086 let raw_string3: str = br####"hello \n"####; 0087 0088 // Invalid 0089 0090 let invalid_binary= 0b1_015; 0091 let invalid_octal = 0o64_92; 0092 let invalid_hexadecimal = 0x7_3AY; 0093 0094 let invalid_char1: char = '\y'; 0095 let invalid_char2: char = '\324'; 0096 let invalid_char3: char = '%%'; 0097 let invalid_char4: char = '\n\dfd'; 0098 let invalid_char5: char = 'aaaaa'; 0099 let open_char: char = '&&&; 0100 0101 let invalid_byte1: u8 = b'ab'; 0102 let invalid_byte2: u8 = b'\b'; 0103 let invalid_byte2: u8 = b'\u{123}'; 0104 0105 let invalid_string: str = "hello \b \u{_123} \u{1234567} \ bye"; 0106 } 0107 0108 //ControlFlow-specific keywords 0109 fn controlflow(y: Vec<usize>) -> usize { 0110 let mut x = 0; 0111 while x < 10 { 0112 if x > 5 { 0113 x = 1; 0114 } 0115 else { 0116 return 5 0117 } 0118 } 0119 loop { 0120 x+= 1; 0121 break; 0122 } 0123 for z in y { 0124 match z { 0125 1 => continue, 0126 _ => x = 2, 0127 } 0128 } 0129 x 0130 }