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