Skip to content

Commit ce3cbff

Browse files
committed
---
yaml --- r: 12184 b: refs/heads/master c: 8e743b2 h: refs/heads/master v: v3
1 parent 64a8566 commit ce3cbff

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 1446534271f01d38ff021cb7f92eb79551f1227b
2+
refs/heads/master: 8e743b2981754f1aa7e0eb5b57d79e5a8ad7d172
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
55
refs/heads/try: 2898dcc5d97da9427ac367542382b6239d9c0bbf

trunk/src/libcore/str.rs

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1485,9 +1485,24 @@ fn as_c_str<T>(s: str, f: fn(*libc::c_char) -> T) -> T unsafe {
14851485
as_buf(s) {|buf| f(buf as *libc::c_char) }
14861486
}
14871487

1488-
#[doc = "Allocate more memory for a string, up to `nn` + 1 bytes"]
1489-
fn reserve(&ss: str, nn: uint) {
1490-
rustrt::str_reserve_shared(ss, nn);
1488+
#[doc = "
1489+
Reserves capacity for exactly `n` bytes in the given string, not including
1490+
the null terminator.
1491+
1492+
Assuming single-byte characters, the resulting string will be large
1493+
enough to hold a string of length `n`. To account for the null terminator,
1494+
the underlying buffer will have the size `n` + 1.
1495+
1496+
If the capacity for `s` is already equal to or greater than the requested
1497+
capacity, then no action is taken.
1498+
1499+
# Arguments
1500+
1501+
* s - A string
1502+
* n - The number of bytes to reserve space for
1503+
"]
1504+
fn reserve(&s: str, n: uint) {
1505+
rustrt::str_reserve_shared(s, n);
14911506
}
14921507

14931508
#[doc = "Unsafe operations"]

0 commit comments

Comments
 (0)