]> git.lizzy.rs Git - rust.git/blobdiff - src/libsemver/lib.rs
libstd: Implement `StrBuf`, a new string buffer type like `Vec`, and
[rust.git] / src / libsemver / lib.rs
index 2663d627e516f1cca6a47119c0d63dab2e02bc68..23d437b0594c833e10f9b8719dd5f7cdd6a8b62a 100644 (file)
@@ -42,6 +42,7 @@
 use std::fmt;
 use std::fmt::Show;
 use std::option::{Option, Some, None};
+use std::strbuf::StrBuf;
 
 /// An identifier in the pre-release or build metadata. If the identifier can
 /// be parsed as a decimal value, it will be represented with `Numeric`.
@@ -158,7 +159,7 @@ fn lt(&self, other: &Version) -> bool {
 
 fn take_nonempty_prefix<T:Iterator<char>>(rdr: &mut T, pred: |char| -> bool)
                         -> (~str, Option<char>) {
-    let mut buf = ~"";
+    let mut buf = StrBuf::new();
     let mut ch = rdr.next();
     loop {
         match ch {
@@ -170,7 +171,7 @@ fn take_nonempty_prefix<T:Iterator<char>>(rdr: &mut T, pred: |char| -> bool)
             }
         }
     }
-    (buf, ch)
+    (buf.into_owned(), ch)
 }
 
 fn take_num<T: Iterator<char>>(rdr: &mut T) -> Option<(uint, Option<char>)> {