Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/cowstr.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use std::{borrow::Cow, ops::Deref};
use std::borrow::Cow;
use std::ops::Deref;

use serde::Deserialize;

Expand Down
7 changes: 3 additions & 4 deletions src/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ use super::Value;
///
/// This trait is sealed and cannot be implemented for types outside of
/// `serde_json_borrow`.

/// # Examples
///
/// ```
Expand All @@ -36,12 +35,12 @@ use super::Value;
pub trait Index<'v> {
/// Return None if the key is not already in the array or object.
#[doc(hidden)]
fn index_into(self, v: &'v Value<'v>) -> Option<&Value<'v>>;
fn index_into(self, v: &'v Value<'v>) -> Option<&'v Value<'v>>;
}

impl<'v> Index<'v> for usize {
#[inline]
fn index_into(self, v: &'v Value<'v>) -> Option<&Value<'v>> {
fn index_into(self, v: &'v Value<'v>) -> Option<&'v Value<'v>> {
match v {
Value::Array(vec) => vec.get(self),
_ => None,
Expand All @@ -51,7 +50,7 @@ impl<'v> Index<'v> for usize {

impl<'v, 'a: 'v> Index<'v> for &'a str {
#[inline]
fn index_into(self, v: &'v Value<'v>) -> Option<&Value<'v>> {
fn index_into(self, v: &'v Value<'v>) -> Option<&'v Value<'v>> {
match v {
Value::Object(map) => map.iter().find(|(k, _v)| k == &self).map(|(_k, v)| v),
_ => None,
Expand Down
Loading