Skip to content

Commit c1e2f4d

Browse files
committed
---
yaml --- r: 63220 b: refs/heads/snap-stage3 c: 8786bca h: refs/heads/master v: v3
1 parent cd1fdd6 commit c1e2f4d

File tree

4 files changed

+35
-33
lines changed

4 files changed

+35
-33
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 2d28d645422c1617be58c8ca7ad9a457264ca850
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 3c23a0a836164ed3ac1b94b526ff8f4e71571e8e
4+
refs/heads/snap-stage3: 8786bca7e2978e6c1d6eed7e61680b0f25db1f18
55
refs/heads/try: 7b78b52e602bb3ea8174f9b2006bff3315f03ef9
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/src/libextra/getopts.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,7 @@ pub mod groups {
593593
*/
594594
pub fn usage(brief: &str, opts: &[OptGroup]) -> ~str {
595595

596-
let desc_sep = ~"\n" + str::repeat(" ", 24);
596+
let desc_sep = ~"\n" + " ".repeat(24);
597597

598598
let rows = vec::map(opts, |optref| {
599599
let OptGroup{short_name: short_name,
@@ -603,7 +603,7 @@ pub mod groups {
603603
hasarg: hasarg,
604604
_} = copy *optref;
605605

606-
let mut row = str::repeat(" ", 4);
606+
let mut row = " ".repeat(4);
607607

608608
// short option
609609
row += match short_name.len() {
@@ -629,7 +629,7 @@ pub mod groups {
629629
// here we just need to indent the start of the description
630630
let rowlen = row.len();
631631
row += if rowlen < 24 {
632-
str::repeat(" ", 24 - rowlen)
632+
" ".repeat(24 - rowlen)
633633
} else {
634634
copy desc_sep
635635
};

branches/snap-stage3/src/librust/rust.rc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ fn usage() {
225225
);
226226

227227
for commands.each |command| {
228-
let padding = str::repeat(" ", indent - command.cmd.len());
228+
let padding = " ".repeat(indent - command.cmd.len());
229229
io::println(fmt!(" %s%s%s",
230230
command.cmd, padding, command.usage_line));
231231
}

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

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -304,29 +304,6 @@ impl<'self> StrVector for &'self [&'self str] {
304304
}
305305
}
306306

307-
/// Given a string, make a new string with repeated copies of it
308-
pub fn repeat(ss: &str, nn: uint) -> ~str {
309-
do as_buf(ss) |buf, len| {
310-
let mut ret = ~"";
311-
// ignore the NULL terminator
312-
let len = len - 1;
313-
ret.reserve(nn * len);
314-
315-
unsafe {
316-
do as_buf(ret) |rbuf, _len| {
317-
let mut rbuf = ::cast::transmute_mut_unsafe(rbuf);
318-
319-
for nn.times {
320-
ptr::copy_memory(rbuf, buf, len);
321-
rbuf = rbuf.offset(len);
322-
}
323-
}
324-
raw::set_len(&mut ret, nn * len);
325-
}
326-
ret
327-
}
328-
}
329-
330307
/*
331308
Section: Adding to and removing from a string
332309
*/
@@ -1567,6 +1544,8 @@ pub trait StrSlice<'self> {
15671544
fn find<C: CharEq>(&self, search: C) -> Option<uint>;
15681545
fn rfind<C: CharEq>(&self, search: C) -> Option<uint>;
15691546
fn find_str(&self, &str) -> Option<uint>;
1547+
1548+
fn repeat(&self, nn: uint) -> ~str;
15701549
}
15711550
15721551
/// Extension methods for strings
@@ -2083,6 +2062,29 @@ impl<'self> StrSlice<'self> for &'self str {
20832062
.map_consume(|(start, _end)| start)
20842063
}
20852064
}
2065+
2066+
/// Given a string, make a new string with repeated copies of it.
2067+
fn repeat(&self, nn: uint) -> ~str {
2068+
do as_buf(*self) |buf, len| {
2069+
let mut ret = ~"";
2070+
// ignore the NULL terminator
2071+
let len = len - 1;
2072+
ret.reserve(nn * len);
2073+
2074+
unsafe {
2075+
do as_buf(ret) |rbuf, _len| {
2076+
let mut rbuf = ::cast::transmute_mut_unsafe(rbuf);
2077+
2078+
for nn.times {
2079+
ptr::copy_memory(rbuf, buf, len);
2080+
rbuf = rbuf.offset(len);
2081+
}
2082+
}
2083+
raw::set_len(&mut ret, nn * len);
2084+
}
2085+
ret
2086+
}
2087+
}
20862088
}
20872089
20882090
#[allow(missing_doc)]
@@ -2541,11 +2543,11 @@ mod tests {
25412543
25422544
#[test]
25432545
fn test_repeat() {
2544-
assert_eq!(repeat("x", 4), ~"xxxx");
2545-
assert_eq!(repeat("hi", 4), ~"hihihihi");
2546-
assert_eq!(repeat("ไท华", 3), ~"ไท华ไท华ไท华");
2547-
assert_eq!(repeat("", 4), ~"");
2548-
assert_eq!(repeat("hi", 0), ~"");
2546+
assert_eq!("x".repeat(4), ~"xxxx");
2547+
assert_eq!("hi".repeat(4), ~"hihihihi");
2548+
assert_eq!("ไท华".repeat(3), ~"ไท华ไท华ไท华");
2549+
assert_eq!("".repeat(4), ~"");
2550+
assert_eq!("hi".repeat(0), ~"");
25492551
}
25502552
25512553
#[test]

0 commit comments

Comments
 (0)