]> git.proxmox.com Git - cargo.git/blobdiff - vendor/serde_json/src/value/index.rs
New upstream version 0.63.1
[cargo.git] / vendor / serde_json / src / value / index.rs
index d759a1df0d527ca53200baf46fc5a78060584707..c74042b75aa022042fd3b75a229a7db85d36d5f4 100644 (file)
@@ -1,6 +1,9 @@
 use super::Value;
-use crate::lib::*;
 use crate::map::Map;
+use alloc::borrow::ToOwned;
+use alloc::string::String;
+use core::fmt::{self, Display};
+use core::ops;
 
 /// A type that can be used to index into a `serde_json::Value`.
 ///
@@ -50,20 +53,20 @@ pub trait Index: private::Sealed {
 
 impl Index for usize {
     fn index_into<'v>(&self, v: &'v Value) -> Option<&'v Value> {
-        match *v {
-            Value::Array(ref vec) => vec.get(*self),
+        match v {
+            Value::Array(vec) => vec.get(*self),
             _ => None,
         }
     }
     fn index_into_mut<'v>(&self, v: &'v mut Value) -> Option<&'v mut Value> {
-        match *v {
-            Value::Array(ref mut vec) => vec.get_mut(*self),
+        match v {
+            Value::Array(vec) => vec.get_mut(*self),
             _ => None,
         }
     }
     fn index_or_insert<'v>(&self, v: &'v mut Value) -> &'v mut Value {
-        match *v {
-            Value::Array(ref mut vec) => {
+        match v {
+            Value::Array(vec) => {
                 let len = vec.len();
                 vec.get_mut(*self).unwrap_or_else(|| {
                     panic!(
@@ -79,23 +82,23 @@ impl Index for usize {
 
 impl Index for str {
     fn index_into<'v>(&self, v: &'v Value) -> Option<&'v Value> {
-        match *v {
-            Value::Object(ref map) => map.get(self),
+        match v {
+            Value::Object(map) => map.get(self),
             _ => None,
         }
     }
     fn index_into_mut<'v>(&self, v: &'v mut Value) -> Option<&'v mut Value> {
-        match *v {
-            Value::Object(ref mut map) => map.get_mut(self),
+        match v {
+            Value::Object(map) => map.get_mut(self),
             _ => None,
         }
     }
     fn index_or_insert<'v>(&self, v: &'v mut Value) -> &'v mut Value {
-        if let Value::Null = *v {
+        if let Value::Null = v {
             *v = Value::Object(Map::new());
         }
-        match *v {
-            Value::Object(ref mut map) => map.entry(self.to_owned()).or_insert(Value::Null),
+        match v {
+            Value::Object(map) => map.entry(self.to_owned()).or_insert(Value::Null),
             _ => panic!("cannot access key {:?} in JSON {}", self, Type(v)),
         }
     }
@@ -133,14 +136,14 @@ mod private {
     pub trait Sealed {}
     impl Sealed for usize {}
     impl Sealed for str {}
-    impl Sealed for super::String {}
+    impl Sealed for alloc::string::String {}
     impl<'a, T> Sealed for &'a T where T: ?Sized + Sealed {}
 }
 
 /// Used in panic messages.
 struct Type<'a>(&'a Value);
 
-impl<'a> fmt::Display for Type<'a> {
+impl<'a> Display for Type<'a> {
     fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
         match *self.0 {
             Value::Null => formatter.write_str("null"),