File tree Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change 1
1
---
2
- refs/heads/master: ad21976fbc4776fe09f98cd087fbe4cecf23cd84
2
+ refs/heads/master: c0a99790cb5cf3ba54954b1b8f7c04f54c42f984
3
3
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4
4
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
5
5
refs/heads/try: 2898dcc5d97da9427ac367542382b6239d9c0bbf
Original file line number Diff line number Diff line change 94
94
char_at,
95
95
reserve,
96
96
reserve_at_least,
97
+ capacity,
97
98
98
99
unsafe ;
99
100
@@ -1530,6 +1531,18 @@ fn reserve_at_least(&s: str, n: uint) unsafe {
1530
1531
reserve ( s, uint:: next_power_of_two ( n + 1 u) - 1 u)
1531
1532
}
1532
1533
1534
+ #[ doc = "
1535
+ Returns the number of single-byte characters the string can hold without
1536
+ reallocating
1537
+ " ]
1538
+ fn capacity ( & & s: str ) -> uint unsafe {
1539
+ as_bytes ( s) { |buf|
1540
+ let vcap = vec:: capacity ( buf) ;
1541
+ assert vcap > 0 u;
1542
+ vcap - 1 u
1543
+ }
1544
+ }
1545
+
1533
1546
#[ doc = "Unsafe operations" ]
1534
1547
mod unsafe {
1535
1548
export
You can’t perform that action at this time.
0 commit comments