Skip to content

Commit 81bcf64

Browse files
committed
---
yaml --- r: 152369 b: refs/heads/try2 c: bbd448a h: refs/heads/master i: 152367: f449d75 v: v3
1 parent cd71b6b commit 81bcf64

File tree

6 files changed

+65
-2
lines changed

6 files changed

+65
-2
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 6b3d3803eb8437907153bbb1b3c3978b29cd3a3b
8+
refs/heads/try2: bbd448a27c37dd95a9551c45606f865bff411a47
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/libcollections/dlist.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
use core::prelude::*;
2525

2626
use alloc::owned::Box;
27+
use core::fmt;
2728
use core::iter;
2829
use core::mem;
2930
use core::ptr;
@@ -608,6 +609,19 @@ impl<A: Clone> Clone for DList<A> {
608609
}
609610
}
610611

612+
impl<A: fmt::Show> fmt::Show for DList<A> {
613+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
614+
try!(write!(f, "["));
615+
616+
for (i, e) in self.iter().enumerate() {
617+
if i != 0 { try!(write!(f, ", ")); }
618+
try!(write!(f, "{}", *e));
619+
}
620+
621+
write!(f, "]")
622+
}
623+
}
624+
611625
#[cfg(test)]
612626
mod tests {
613627
use std::prelude::*;
@@ -1027,6 +1041,17 @@ mod tests {
10271041
}
10281042
}
10291043

1044+
#[test]
1045+
fn test_show() {
1046+
let list: DList<int> = range(0, 10).collect();
1047+
assert!(list.to_str().as_slice() == "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]");
1048+
1049+
let list: DList<&str> = vec!["just", "one", "test", "more"].iter()
1050+
.map(|&s| s)
1051+
.collect();
1052+
assert!(list.to_str().as_slice() == "[just, one, test, more]");
1053+
}
1054+
10301055
#[cfg(test)]
10311056
fn fuzz_test(sz: int) {
10321057
let mut m: DList<int> = DList::new();

branches/try2/src/libcollections/smallintmap.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
use core::prelude::*;
1919

20+
use core::fmt;
2021
use core::iter::{Enumerate, FilterMap};
2122
use core::mem::replace;
2223

@@ -176,6 +177,18 @@ impl<V:Clone> SmallIntMap<V> {
176177
}
177178
}
178179

180+
impl<V: fmt::Show> fmt::Show for SmallIntMap<V> {
181+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
182+
try!(write!(f, r"\{"));
183+
184+
for (i, (k, v)) in self.iter().enumerate() {
185+
if i != 0 { try!(write!(f, ", ")); }
186+
try!(write!(f, "{}: {}", k, *v));
187+
}
188+
189+
write!(f, r"\}")
190+
}
191+
}
179192

180193
macro_rules! iterator {
181194
(impl $name:ident -> $elem:ty, $getter:ident) => {
@@ -461,6 +474,20 @@ mod test_map {
461474
assert!(called);
462475
m.insert(2, box 1);
463476
}
477+
478+
#[test]
479+
fn test_show() {
480+
let mut map = SmallIntMap::new();
481+
let empty = SmallIntMap::<int>::new();
482+
483+
map.insert(1, 2);
484+
map.insert(3, 4);
485+
486+
let map_str = map.to_str();
487+
let map_str = map_str.as_slice();
488+
assert!(map_str == "{1: 2, 3: 4}" || map_str == "{3: 4, 1: 2}");
489+
assert_eq!(format!("{}", empty), "{}".to_string());
490+
}
464491
}
465492

466493
#[cfg(test)]

branches/try2/src/librustdoc/html/static/playpen.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
a.attr('target', '_blank');
2323
$(this).append(a);
2424
}, function() {
25-
$(this).find('a').remove();
25+
$(this).find('a.test-arrow').remove();
2626
});
2727
}
2828
}());

branches/try2/src/libsyntax/ext/quote.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,12 @@ pub mod rt {
135135
}
136136
}
137137

138+
impl ToSource for ast::Arg {
139+
fn to_source(&self) -> String {
140+
pprust::arg_to_str(self)
141+
}
142+
}
143+
138144
impl<'a> ToSource for &'a str {
139145
fn to_source(&self) -> String {
140146
let lit = dummy_spanned(ast::LitStr(
@@ -264,6 +270,7 @@ pub mod rt {
264270
impl_to_tokens!(Generics)
265271
impl_to_tokens!(@ast::Expr)
266272
impl_to_tokens!(ast::Block)
273+
impl_to_tokens!(ast::Arg)
267274
impl_to_tokens_self!(&'a str)
268275
impl_to_tokens!(())
269276
impl_to_tokens!(char)

branches/try2/src/libsyntax/print/pprust.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,10 @@ pub fn variant_to_str(var: &ast::Variant) -> String {
242242
to_str(|s| s.print_variant(var))
243243
}
244244

245+
pub fn arg_to_str(arg: &ast::Arg) -> String {
246+
to_str(|s| s.print_arg(arg))
247+
}
248+
245249
pub fn visibility_qualified(vis: ast::Visibility, s: &str) -> String {
246250
match vis {
247251
ast::Public => format!("pub {}", s).to_string(),

0 commit comments

Comments
 (0)