Skip to content

Commit bdc1b7a

Browse files
committed
libcore: add a str::with_capacity to match the fn in vec
1 parent 22efa39 commit bdc1b7a

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/libcore/str.rs

+5
Original file line numberDiff line numberDiff line change
@@ -1473,6 +1473,11 @@ pub pure fn from_utf16(v: &[u16]) -> ~str {
14731473
move buf
14741474
}
14751475

1476+
pub pure fn with_capacity(capacity: uint) -> ~str {
1477+
let mut buf = ~"";
1478+
unsafe { reserve(&mut buf, capacity); }
1479+
move buf
1480+
}
14761481

14771482
/**
14781483
* As char_len but for a slice of a string

0 commit comments

Comments
 (0)