Skip to content

Commit ab5d2f3

Browse files
killerswanbrson
authored andcommitted
---
yaml --- r: 7986 b: refs/heads/snap-stage3 c: 4e406d7 h: refs/heads/master v: v3
1 parent 846b29b commit ab5d2f3

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
refs/heads/master: 2898dcc5d97da9427ac367542382b6239d9c0bbf
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: cccf9e5389eaeb93566c83da266aa5df70be812c
4+
refs/heads/snap-stage3: 4e406d7fdd55c6c499eb3af750c64292a88e4d9f
55
refs/heads/try: 2898dcc5d97da9427ac367542382b6239d9c0bbf
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105

branches/snap-stage3/src/libcore/str.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ Failure:
424424
425425
If `begin` + `len` is is greater than the byte length of the string
426426
*/
427-
fn substr(s: str, begin: uint, len: uint) -> str {
427+
fn substr(s: str, begin: uint, len: uint) -> str unsafe {
428428
ret unsafe::slice(s, begin, begin + len);
429429
}
430430

@@ -706,13 +706,14 @@ Returns:
706706
707707
The original string with all occurances of `from` replaced with `to`
708708
*/
709-
fn replace(s: str, from: str, to: str) : is_not_empty(from) -> str {
709+
fn replace(s: str, from: str, to: str) : is_not_empty(from) -> str unsafe {
710710
// FIXME (694): Shouldn't have to check this
711711
check (is_not_empty(from));
712712
if byte_len(s) == 0u {
713713
ret "";
714714
} else if starts_with(s, from) {
715-
ret to + replace(unsafe::slice(s, byte_len(from), byte_len(s)), from, to);
715+
ret to + replace(unsafe::slice(s, byte_len(from), byte_len(s)),
716+
from, to);
716717
} else {
717718
let idx = find(s, from);
718719
if idx == -1 {
@@ -1401,7 +1402,8 @@ mod unsafe {
14011402
14021403
FIXME: rename to safe_range_byte_slice
14031404
*/
1404-
unsafe fn safe_slice(s: str, begin: uint, end: uint) : uint::le(begin, end) -> str {
1405+
unsafe fn safe_slice(s: str, begin: uint, end: uint)
1406+
: uint::le(begin, end) -> str {
14051407
// would need some magic to make this a precondition
14061408
assert (end <= byte_len(s));
14071409
ret slice(s, begin, end);
@@ -1634,7 +1636,7 @@ mod tests {
16341636
}
16351637

16361638
#[test]
1637-
fn test_slice() {
1639+
fn test_unsafe_slice() unsafe {
16381640
assert (eq("ab", slice("abc", 0u, 2u)));
16391641
assert (eq("bc", slice("abc", 1u, 3u)));
16401642
assert (eq("", slice("abc", 1u, 1u)));
@@ -1651,7 +1653,7 @@ mod tests {
16511653
ret rs;
16521654
}
16531655
assert (eq(half_a_million_letter_a(),
1654-
slice(a_million_letter_a(), 0u, 500000u)));
1656+
unsafe::slice(a_million_letter_a(), 0u, 500000u)));
16551657
}
16561658

16571659
#[test]

0 commit comments

Comments
 (0)