Skip to content

Commit 10db871

Browse files
committed
---
yaml --- r: 120319 b: refs/heads/dist-snap c: 5a93b4f h: refs/heads/master i: 120317: 6418c91 120315: cfacfcb 120311: 8898a59 120303: cff0dd7 120287: 1e2f693 120255: e662239 120191: e55e42f 120063: 59a5994 119807: a6036e3 v: v3
1 parent 10478b3 commit 10db871

File tree

2 files changed

+26
-22
lines changed

2 files changed

+26
-22
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ refs/heads/try: 1813e5aa1a03b0596b8de7abd1af31edf5d6098f
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
9-
refs/heads/dist-snap: 30dbcf5f88b20db3ea1c70bb50cb37fa9364f1a9
9+
refs/heads/dist-snap: 5a93b4f192bfc8cba24b9c51e8a70a9b51e96b05
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1212
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0

branches/dist-snap/src/libsemver/lib.rs

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ use std::strbuf::StrBuf;
5050
#[allow(missing_doc)]
5151
pub enum Identifier {
5252
Numeric(uint),
53-
AlphaNumeric(~str)
53+
AlphaNumeric(StrBuf)
5454
}
5555

5656
impl cmp::Ord for Identifier {
@@ -158,7 +158,7 @@ impl cmp::Ord for Version {
158158
}
159159

160160
fn take_nonempty_prefix<T:Iterator<char>>(rdr: &mut T, pred: |char| -> bool)
161-
-> (~str, Option<char>) {
161+
-> (StrBuf, Option<char>) {
162162
let mut buf = StrBuf::new();
163163
let mut ch = rdr.next();
164164
loop {
@@ -171,21 +171,21 @@ fn take_nonempty_prefix<T:Iterator<char>>(rdr: &mut T, pred: |char| -> bool)
171171
}
172172
}
173173
}
174-
(buf.into_owned(), ch)
174+
(buf, ch)
175175
}
176176

177177
fn take_num<T: Iterator<char>>(rdr: &mut T) -> Option<(uint, Option<char>)> {
178178
let (s, ch) = take_nonempty_prefix(rdr, char::is_digit);
179-
match from_str::<uint>(s) {
179+
match from_str::<uint>(s.as_slice()) {
180180
None => None,
181181
Some(i) => Some((i, ch))
182182
}
183183
}
184184

185185
fn take_ident<T: Iterator<char>>(rdr: &mut T) -> Option<(Identifier, Option<char>)> {
186186
let (s,ch) = take_nonempty_prefix(rdr, char::is_alphanumeric);
187-
if s.chars().all(char::is_digit) {
188-
match from_str::<uint>(s) {
187+
if s.as_slice().chars().all(char::is_digit) {
188+
match from_str::<uint>(s.as_slice()) {
189189
None => None,
190190
Some(i) => Some((Numeric(i), ch))
191191
}
@@ -308,52 +308,52 @@ fn test_parse() {
308308
major: 1u,
309309
minor: 2u,
310310
patch: 3u,
311-
pre: vec!(AlphaNumeric("alpha1".to_owned())),
311+
pre: vec!(AlphaNumeric("alpha1".to_strbuf())),
312312
build: vec!(),
313313
}));
314314
assert!(parse(" 1.2.3-alpha1 ") == Some(Version {
315315
major: 1u,
316316
minor: 2u,
317317
patch: 3u,
318-
pre: vec!(AlphaNumeric("alpha1".to_owned())),
318+
pre: vec!(AlphaNumeric("alpha1".to_strbuf())),
319319
build: vec!()
320320
}));
321321
assert!(parse("1.2.3+build5") == Some(Version {
322322
major: 1u,
323323
minor: 2u,
324324
patch: 3u,
325325
pre: vec!(),
326-
build: vec!(AlphaNumeric("build5".to_owned()))
326+
build: vec!(AlphaNumeric("build5".to_strbuf()))
327327
}));
328328
assert!(parse(" 1.2.3+build5 ") == Some(Version {
329329
major: 1u,
330330
minor: 2u,
331331
patch: 3u,
332332
pre: vec!(),
333-
build: vec!(AlphaNumeric("build5".to_owned()))
333+
build: vec!(AlphaNumeric("build5".to_strbuf()))
334334
}));
335335
assert!(parse("1.2.3-alpha1+build5") == Some(Version {
336336
major: 1u,
337337
minor: 2u,
338338
patch: 3u,
339-
pre: vec!(AlphaNumeric("alpha1".to_owned())),
340-
build: vec!(AlphaNumeric("build5".to_owned()))
339+
pre: vec!(AlphaNumeric("alpha1".to_strbuf())),
340+
build: vec!(AlphaNumeric("build5".to_strbuf()))
341341
}));
342342
assert!(parse(" 1.2.3-alpha1+build5 ") == Some(Version {
343343
major: 1u,
344344
minor: 2u,
345345
patch: 3u,
346-
pre: vec!(AlphaNumeric("alpha1".to_owned())),
347-
build: vec!(AlphaNumeric("build5".to_owned()))
346+
pre: vec!(AlphaNumeric("alpha1".to_strbuf())),
347+
build: vec!(AlphaNumeric("build5".to_strbuf()))
348348
}));
349349
assert!(parse("1.2.3-1.alpha1.9+build5.7.3aedf ") == Some(Version {
350350
major: 1u,
351351
minor: 2u,
352352
patch: 3u,
353-
pre: vec!(Numeric(1),AlphaNumeric("alpha1".to_owned()),Numeric(9)),
354-
build: vec!(AlphaNumeric("build5".to_owned()),
353+
pre: vec!(Numeric(1),AlphaNumeric("alpha1".to_strbuf()),Numeric(9)),
354+
build: vec!(AlphaNumeric("build5".to_strbuf()),
355355
Numeric(7),
356-
AlphaNumeric("3aedf".to_owned()))
356+
AlphaNumeric("3aedf".to_strbuf()))
357357
}));
358358

359359
}
@@ -377,10 +377,14 @@ fn test_ne() {
377377

378378
#[test]
379379
fn test_show() {
380-
assert_eq!(format!("{}", parse("1.2.3").unwrap()), "1.2.3".to_owned());
381-
assert_eq!(format!("{}", parse("1.2.3-alpha1").unwrap()), "1.2.3-alpha1".to_owned());
382-
assert_eq!(format!("{}", parse("1.2.3+build.42").unwrap()), "1.2.3+build.42".to_owned());
383-
assert_eq!(format!("{}", parse("1.2.3-alpha1+42").unwrap()), "1.2.3-alpha1+42".to_owned());
380+
assert_eq!(format_strbuf!("{}", parse("1.2.3").unwrap()),
381+
"1.2.3".to_strbuf());
382+
assert_eq!(format_strbuf!("{}", parse("1.2.3-alpha1").unwrap()),
383+
"1.2.3-alpha1".to_strbuf());
384+
assert_eq!(format_strbuf!("{}", parse("1.2.3+build.42").unwrap()),
385+
"1.2.3+build.42".to_strbuf());
386+
assert_eq!(format_strbuf!("{}", parse("1.2.3-alpha1+42").unwrap()),
387+
"1.2.3-alpha1+42".to_strbuf());
384388
}
385389

386390
#[test]

0 commit comments

Comments
 (0)