@@ -7,7 +7,7 @@ use std::io::IoResult;
7
7
#[ deriving( Clone ) ]
8
8
pub struct ParseBranch {
9
9
matches : Vec < u8 > ,
10
- result : Option < StrBuf > ,
10
+ result : Option < String > ,
11
11
children : Vec < ParseBranch > ,
12
12
}
13
13
@@ -27,7 +27,7 @@ pub fn branchify(options: &[(&str, &str)], case_sensitive: bool) -> Vec<ParseBra
27
27
fn go_down_moses ( branch : & mut ParseBranch , mut chariter : Chars , result : & str , case_sensitive : bool ) {
28
28
match chariter. next ( ) {
29
29
Some ( c) => {
30
- let first_case = if case_sensitive { c as u8 } else { c. to_ascii ( ) . to_upper ( ) . to_byte ( ) } ;
30
+ let first_case = if case_sensitive { c as u8 } else { c. to_ascii ( ) . to_uppercase ( ) . to_byte ( ) } ;
31
31
for next_branch in branch. children . mut_iter ( ) {
32
32
if * next_branch. matches . get ( 0 ) == first_case {
33
33
go_down_moses ( next_branch, chariter, result, case_sensitive) ;
@@ -37,7 +37,7 @@ pub fn branchify(options: &[(&str, &str)], case_sensitive: bool) -> Vec<ParseBra
37
37
let mut subbranch = ParseBranch :: new ( ) ;
38
38
subbranch. matches . push ( first_case) ;
39
39
if !case_sensitive {
40
- let second_case = c. to_ascii ( ) . to_lower ( ) . to_byte ( ) ;
40
+ let second_case = c. to_ascii ( ) . to_lowercase ( ) . to_byte ( ) ;
41
41
if first_case != second_case {
42
42
subbranch. matches . push ( second_case) ;
43
43
}
@@ -48,7 +48,7 @@ pub fn branchify(options: &[(&str, &str)], case_sensitive: bool) -> Vec<ParseBra
48
48
} ,
49
49
None => {
50
50
assert ! ( branch. result. is_none( ) ) ;
51
- branch. result = Some ( StrBuf :: from_str ( result) ) ;
51
+ branch. result = Some ( String :: from_str ( result) ) ;
52
52
} ,
53
53
}
54
54
} ;
@@ -78,7 +78,7 @@ macro_rules! branchify(
78
78
/// :param max_len: the maximum length a value may be before giving up and returning ``None``
79
79
/// :param valid: the function call to if a byte ``b`` is valid
80
80
/// :param unknown: the expression to call for an unknown value; in this string, ``{}`` will be
81
- /// replaced with an expression (literal or non-literal) evaluating to a ``StrBuf `` (it is
81
+ /// replaced with an expression (literal or non-literal) evaluating to a ``String `` (it is
82
82
/// ``{}`` only, not arbitrary format strings)
83
83
pub fn generate_branchified_method (
84
84
writer : & mut Writer ,
@@ -102,13 +102,13 @@ pub fn generate_branchified_method(
102
102
let next_prefix = format ! ( "{}{}" , prefix, c as char ) ;
103
103
w ! ( format!( "Ok(b) if b == '{}' as u8 => match {} \\ {" , c as char , read_call) ) ;
104
104
for b in branch. children . iter ( ) {
105
- try!( r ( writer, b, next_prefix, indent + 1 , read_call, end, max_len, valid, unknown) ) ;
105
+ try!( r ( writer, b, next_prefix. as_slice ( ) , indent + 1 , read_call, end, max_len, valid, unknown) ) ;
106
106
}
107
107
match branch. result {
108
108
Some ( ref result) =>
109
109
w ! ( format!( " Ok(b) if b == SP => return Ok({})," , * result) ) ,
110
110
None => w ! ( format!( " Ok(b) if b == SP => return Ok({})," ,
111
- unknown. replace( "{}" , format!( "StrBuf ::from_str(\" {}\" )" , next_prefix) ) ) ) ,
111
+ unknown. replace( "{}" , format!( "String ::from_str(\" {}\" )" , next_prefix) . as_slice ( ) ) ) ) ,
112
112
}
113
113
w ! ( format!( " Ok(b) if {} => (\" {}\" , b)," , valid, next_prefix) ) ;
114
114
w ! ( " Ok(_) => return Err(::std::io::IoError { kind: ::std::io::OtherIoError, desc: \" bad value\" , detail: None })," ) ;
@@ -133,7 +133,7 @@ pub fn generate_branchified_method(
133
133
w ! ( ( " Err(err) => return Err(err)," ) ) ;
134
134
w ! ( ( "};" ) ) ;
135
135
w ! ( ( "// OK, that didn't pan out. Let's read the rest and see what we get." ) ) ;
136
- w ! ( ( "let mut s = StrBuf ::from_str(s);" ) ) ;
136
+ w ! ( ( "let mut s = String ::from_str(s);" ) ) ;
137
137
w ! ( ( "s.push_char(next_byte as char);" ) ) ;
138
138
w ! ( ( "loop {" ) ) ;
139
139
w ! ( format!( " match {} \\ {" , read_call) ) ;
0 commit comments