aboutsummaryrefslogtreecommitdiff
path: root/src/map.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/map.rs')
-rw-r--r--src/map.rs30
1 files changed, 15 insertions, 15 deletions
diff --git a/src/map.rs b/src/map.rs
index 59ae24e..b6e00b0 100644
--- a/src/map.rs
+++ b/src/map.rs
@@ -14,12 +14,12 @@
//! [`BTreeMap`]: https://doc.rust-lang.org/std/collections/struct.BTreeMap.html
//! [`LinkedHashMap`]: https://docs.rs/linked-hash-map/*/linked_hash_map/struct.LinkedHashMap.html
+use crate::value::Value;
use serde::{de, ser};
+use std::borrow::Borrow;
use std::fmt::{self, Debug};
-use value::Value;
use std::hash::Hash;
use std::iter::FromIterator;
-use std::borrow::Borrow;
use std::ops;
#[cfg(not(feature = "preserve_order"))]
@@ -140,14 +140,14 @@ impl Map<String, Value> {
/// Gets the given key's corresponding entry in the map for in-place
/// manipulation.
- pub fn entry<S>(&mut self, key: S) -> Entry
+ pub fn entry<S>(&mut self, key: S) -> Entry<'_>
where
S: Into<String>,
{
- #[cfg(not(feature = "preserve_order"))]
- use std::collections::btree_map::Entry as EntryImpl;
#[cfg(feature = "preserve_order")]
use linked_hash_map::Entry as EntryImpl;
+ #[cfg(not(feature = "preserve_order"))]
+ use std::collections::btree_map::Entry as EntryImpl;
match self.map.entry(key.into()) {
EntryImpl::Vacant(vacant) => Entry::Vacant(VacantEntry { vacant: vacant }),
@@ -169,7 +169,7 @@ impl Map<String, Value> {
/// Gets an iterator over the entries of the map.
#[inline]
- pub fn iter(&self) -> Iter {
+ pub fn iter(&self) -> Iter<'_> {
Iter {
iter: self.map.iter(),
}
@@ -177,7 +177,7 @@ impl Map<String, Value> {
/// Gets a mutable iterator over the entries of the map.
#[inline]
- pub fn iter_mut(&mut self) -> IterMut {
+ pub fn iter_mut(&mut self) -> IterMut<'_> {
IterMut {
iter: self.map.iter_mut(),
}
@@ -185,7 +185,7 @@ impl Map<String, Value> {
/// Gets an iterator over the keys of the map.
#[inline]
- pub fn keys(&self) -> Keys {
+ pub fn keys(&self) -> Keys<'_> {
Keys {
iter: self.map.keys(),
}
@@ -193,7 +193,7 @@ impl Map<String, Value> {
/// Gets an iterator over the values of the map.
#[inline]
- pub fn values(&self) -> Values {
+ pub fn values(&self) -> Values<'_> {
Values {
iter: self.map.values(),
}
@@ -253,7 +253,7 @@ where
impl Debug for Map<String, Value> {
#[inline]
- fn fmt(&self, formatter: &mut fmt::Formatter) -> Result<(), fmt::Error> {
+ fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
self.map.fmt(formatter)
}
}
@@ -265,10 +265,10 @@ impl ser::Serialize for Map<String, Value> {
S: ser::Serializer,
{
use serde::ser::SerializeMap;
- let mut map = try!(serializer.serialize_map(Some(self.len())));
+ let mut map = serializer.serialize_map(Some(self.len()))?;
for (k, v) in self {
- try!(map.serialize_key(k));
- try!(map.serialize_value(v));
+ map.serialize_key(k)?;
+ map.serialize_value(v)?;
}
map.end()
}
@@ -285,7 +285,7 @@ impl<'de> de::Deserialize<'de> for Map<String, Value> {
impl<'de> de::Visitor<'de> for Visitor {
type Value = Map<String, Value>;
- fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
+ fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
formatter.write_str("a map")
}
@@ -304,7 +304,7 @@ impl<'de> de::Deserialize<'de> for Map<String, Value> {
{
let mut values = Map::new();
- while let Some((key, value)) = try!(visitor.next_entry()) {
+ while let Some((key, value)) = visitor.next_entry()? {
values.insert(key, value);
}