@@ -49,7 +49,7 @@ pub pure fn from_byte(b: u8) -> ~str {
49
49
}
50
50
51
51
/// Appends a character at the end of a string
52
- pub fn push_char( s : & const ~str , ch : char ) {
52
+ pub fn push_char( s : & mut ~str , ch : char ) {
53
53
unsafe {
54
54
let code = ch as uint ;
55
55
let nb = if code < max_one_b { 1 u }
@@ -140,7 +140,7 @@ pub pure fn from_chars(chs: &[char]) -> ~str {
140
140
141
141
/// Appends a string slice to the back of a string, without overallocating
142
142
#[ inline( always) ]
143
- pub fn push_str_no_overallocate ( lhs : & const ~str , rhs : & str ) {
143
+ pub fn push_str_no_overallocate ( lhs : & mut ~str , rhs : & str ) {
144
144
unsafe {
145
145
let llen = lhs. len ( ) ;
146
146
let rlen = rhs. len ( ) ;
@@ -157,7 +157,7 @@ pub fn push_str_no_overallocate(lhs: &const ~str, rhs: &str) {
157
157
}
158
158
/// Appends a string slice to the back of a string
159
159
#[ inline( always) ]
160
- pub fn push_str ( lhs : & const ~str , rhs : & str ) {
160
+ pub fn push_str ( lhs : & mut ~str , rhs : & str ) {
161
161
unsafe {
162
162
let llen = lhs. len ( ) ;
163
163
let rlen = rhs. len ( ) ;
@@ -214,7 +214,7 @@ Section: Adding to and removing from a string
214
214
*
215
215
* If the string does not contain any characters
216
216
*/
217
- pub fn pop_char ( s : & const ~str ) -> char {
217
+ pub fn pop_char ( s : & mut ~str ) -> char {
218
218
let end = len ( * s) ;
219
219
assert end > 0 u;
220
220
let { ch, prev} = char_range_at_reverse ( * s, end) ;
@@ -1802,9 +1802,9 @@ pub pure fn as_buf<T>(s: &str, f: fn(*u8, uint) -> T) -> T {
1802
1802
* * s - A string
1803
1803
* * n - The number of bytes to reserve space for
1804
1804
*/
1805
- pub fn reserve ( s : & const ~str , n : uint ) {
1805
+ pub fn reserve ( s : & mut ~str , n : uint ) {
1806
1806
unsafe {
1807
- let v: * mut ~[ u8 ] = cast:: transmute ( copy s) ;
1807
+ let v: * mut ~[ u8 ] = cast:: transmute ( s) ;
1808
1808
vec:: reserve ( & mut * v, n + 1 ) ;
1809
1809
}
1810
1810
}
@@ -1829,7 +1829,7 @@ pub fn reserve(s: &const ~str, n: uint) {
1829
1829
* * s - A string
1830
1830
* * n - The number of bytes to reserve space for
1831
1831
*/
1832
- pub fn reserve_at_least ( s : & const ~str , n : uint ) {
1832
+ pub fn reserve_at_least ( s : & mut ~str , n : uint ) {
1833
1833
reserve ( s, uint:: next_power_of_two ( n + 1 u) - 1 u)
1834
1834
}
1835
1835
@@ -1974,7 +1974,7 @@ pub mod raw {
1974
1974
}
1975
1975
1976
1976
/// Appends a byte to a string. (Not UTF-8 safe).
1977
- pub unsafe fn push_byte ( s : & const ~str , b : u8 ) {
1977
+ pub unsafe fn push_byte ( s : & mut ~str , b : u8 ) {
1978
1978
reserve_at_least ( s, s. len ( ) + 1 ) ;
1979
1979
do as_buf( * s) |buf, len| {
1980
1980
let buf: * mut u8 = :: cast:: reinterpret_cast ( & buf) ;
@@ -1984,13 +1984,13 @@ pub mod raw {
1984
1984
}
1985
1985
1986
1986
/// Appends a vector of bytes to a string. (Not UTF-8 safe).
1987
- unsafe fn push_bytes ( s : & const ~str , bytes : & [ u8 ] ) {
1987
+ unsafe fn push_bytes ( s : & mut ~str , bytes : & [ u8 ] ) {
1988
1988
reserve_at_least ( s, s. len ( ) + bytes. len ( ) ) ;
1989
1989
for vec:: each( bytes) |byte| { push_byte ( s, * byte) ; }
1990
1990
}
1991
1991
1992
1992
/// Removes the last byte from a string and returns it. (Not UTF-8 safe).
1993
- pub unsafe fn pop_byte ( s : & const ~str ) -> u8 {
1993
+ pub unsafe fn pop_byte ( s : & mut ~str ) -> u8 {
1994
1994
let len = len ( * s) ;
1995
1995
assert ( len > 0 u) ;
1996
1996
let b = s[ len - 1 u] ;
@@ -2008,7 +2008,7 @@ pub mod raw {
2008
2008
}
2009
2009
2010
2010
/// Sets the length of the string and adds the null terminator
2011
- pub unsafe fn set_len ( v : & const ~str , new_len : uint ) {
2011
+ pub unsafe fn set_len ( v : & mut ~str , new_len : uint ) {
2012
2012
let v: * * vec:: raw:: VecRepr = cast:: transmute ( copy v) ;
2013
2013
let repr: * vec:: raw:: VecRepr = * v;
2014
2014
( * repr) . unboxed . fill = new_len + 1 u;
0 commit comments