Allow pub-keyword for impl-block
This commit is contained in:
		
							parent
							
								
									a6a903a45d
								
							
						
					
					
						commit
						9d5a20e76a
					
				| @ -1,5 +1,4 @@ | ||||
| import std::print; | ||||
| import std::from_str; | ||||
| import std::add_char; | ||||
| import std::set_char; | ||||
| import std::free_string; | ||||
| @ -8,7 +7,7 @@ import std::add_num_to_str; | ||||
| import std::concat_strings; | ||||
| 
 | ||||
| fn main() { | ||||
|     let mut test = from_str("hello"); | ||||
|     let mut test = String::new(); | ||||
| 
 | ||||
|     concat_strings(&mut test, from_str(" world")); | ||||
| 
 | ||||
|  | ||||
| @ -11,6 +11,17 @@ struct String { | ||||
|     must_be_freed: bool, | ||||
| } | ||||
| 
 | ||||
| impl String { | ||||
|     pub fn new() -> String { | ||||
|         String { | ||||
|             inner: char::alloca(0), | ||||
|             length: 0, | ||||
|             max_length: 0, | ||||
|             must_be_freed: true, | ||||
|         } | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| impl binop (lhs: String) + (rhs: *char) -> String { | ||||
|     let mut new = lhs; | ||||
|     let added = from_str(rhs); | ||||
|  | ||||
| @ -1052,7 +1052,9 @@ impl Parse for AssociatedFunctionBlock { | ||||
|         let ty = stream.parse::<Type>()?; | ||||
|         stream.expect(Token::BraceOpen)?; | ||||
|         let mut functions = Vec::new(); | ||||
|         while let Some(Token::FnKeyword) = stream.peek() { | ||||
|         loop { | ||||
|             match stream.peek() { | ||||
|                 Some(Token::FnKeyword) | Some(Token::PubKeyword) => { | ||||
|                     let mut fun: FunctionDefinition = stream.parse()?; | ||||
|                     fun.0.self_kind = match fun.0.self_kind { | ||||
|                         SelfKind::Owned(_) => SelfKind::Owned(ty.0.clone()), | ||||
| @ -1062,6 +1064,9 @@ impl Parse for AssociatedFunctionBlock { | ||||
|                     }; | ||||
|                     functions.push(fun); | ||||
|                 } | ||||
|                 _ => break, | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         stream.expect(Token::BraceClose)?; | ||||
|         Ok(AssociatedFunctionBlock(ty, functions)) | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user