about summary refs log tree commit diff
path: root/src/librustc_data_structures/small_vec.rs
diff options
context:
space:
mode:
authorljedrz <ljedrz@gmail.com>2018-07-24 15:29:31 +0200
committerljedrz <ljedrz@gmail.com>2018-07-24 15:29:31 +0200
commit86d0e9e1c765f434cc31933a970d1c1c1cfebea7 (patch)
tree80c1757df0ca4b44ac446b907e3a45db560a15d8 /src/librustc_data_structures/small_vec.rs
parentbaba5007bf857b4577a8d26de454a03d7afef3ac (diff)
downloadrust-86d0e9e1c765f434cc31933a970d1c1c1cfebea7.tar.gz
rust-86d0e9e1c765f434cc31933a970d1c1c1cfebea7.zip
Simplify a few functions in rustc_data_structures
Diffstat (limited to 'src/librustc_data_structures/small_vec.rs')
-rw-r--r--src/librustc_data_structures/small_vec.rs8
1 files changed, 2 insertions, 6 deletions
diff --git a/src/librustc_data_structures/small_vec.rs b/src/librustc_data_structures/small_vec.rs
index 83eb54fade1..4a72ab57fcc 100644
--- a/src/librustc_data_structures/small_vec.rs
+++ b/src/librustc_data_structures/small_vec.rs
@@ -197,7 +197,7 @@ impl<A> Encodable for SmallVec<A>
     fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> {
         s.emit_seq(self.len(), |s| {
             for (i, e) in self.iter().enumerate() {
-                try!(s.emit_seq_elt(i, |s| e.encode(s)));
+                s.emit_seq_elt(i, |s| e.encode(s))?;
             }
             Ok(())
         })
@@ -209,11 +209,7 @@ impl<A> Decodable for SmallVec<A>
           A::Element: Decodable {
     fn decode<D: Decoder>(d: &mut D) -> Result<SmallVec<A>, D::Error> {
         d.read_seq(|d, len| {
-            let mut vec = SmallVec::with_capacity(len);
-            for i in 0..len {
-                vec.push(try!(d.read_seq_elt(i, |d| Decodable::decode(d))));
-            }
-            Ok(vec)
+            (0..len).map(|i| d.read_seq_elt(i, |d| Decodable::decode(d))).collect()
         })
     }
 }