Skip to content

Commit

Permalink
Make clippy happy
Browse files Browse the repository at this point in the history
Signed-off-by: Heinz N. Gies <[email protected]>
  • Loading branch information
Licenser committed Jul 6, 2024
1 parent 62e5916 commit 19228a6
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 33 deletions.
File renamed without changes.
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ name = "perf"
codegen-units = 1
lto = true
opt-level = 3
panic = "abort"


[profile.release]
Expand Down
8 changes: 7 additions & 1 deletion src/value/lazy.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::cow::Cow;
use crate::prelude::*;
use crate::{borrowed, tape};
use std::borrow::Cow;
use std::fmt;

mod array;
Expand Down Expand Up @@ -237,10 +237,16 @@ impl<'tape, 'value> ValueIntoString for Value<'tape, 'value> {
// This is a bit complex but it allows us to avoid cloning
Value::Value(value) => match value {
Cow::Borrowed(value) => match value {
#[cfg(feature = "beef")]
borrowed::Value::String(s) => Some(s.clone().into()),
#[cfg(not(feature = "beef"))]
borrowed::Value::String(s) => Some(s.clone()),
_ => None,
},
Cow::Owned(value) => match value {
#[cfg(feature = "beef")]
borrowed::Value::String(s) => Some(s.into()),
#[cfg(not(feature = "beef"))]
borrowed::Value::String(s) => Some(s),
_ => None,
},
Expand Down
54 changes: 27 additions & 27 deletions src/value/lazy/from.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use super::Value;
use crate::StaticNode;
use crate::{borrowed, cow::Cow};

use std::borrow::Cow as StdCow;
impl<'tape, 'value> From<StaticNode> for Value<'tape, 'value> {
#[cfg_attr(not(feature = "no-inline"), inline)]
#[must_use]
fn from(v: StaticNode) -> Self {
Value::Value(Cow::Owned(borrowed::Value::from(v)))
Value::Value(StdCow::Owned(borrowed::Value::from(v)))
}
}

Expand All @@ -17,15 +17,15 @@ where
#[cfg_attr(not(feature = "no-inline"), inline)]
#[must_use]
fn from(v: Option<T>) -> Self {
Value::Value(Cow::Owned(borrowed::Value::from(v)))
Value::Value(StdCow::Owned(borrowed::Value::from(v)))
}
}
/********* str_ **********/
impl<'tape, 'value> From<&'value str> for Value<'tape, 'value> {
#[cfg_attr(not(feature = "no-inline"), inline)]
#[must_use]
fn from(v: &'value str) -> Self {
Value::Value(Cow::Owned(borrowed::Value::from(v)))
Value::Value(StdCow::Owned(borrowed::Value::from(v)))
}
}

Expand All @@ -34,7 +34,7 @@ impl<'tape, 'value> From<std::borrow::Cow<'value, str>> for Value<'tape, 'value>
#[cfg_attr(not(feature = "no-inline"), inline)]
#[must_use]
fn from(v: std::borrow::Cow<'value, str>) -> Self {
Value::Value(Cow::Owned(borrowed::Value::from(v)))
Value::Value(StdCow::Owned(borrowed::Value::from(v)))
}
}

Expand All @@ -43,7 +43,7 @@ impl<'tape, 'value> From<std::borrow::Cow<'value, str>> for Value<'tape, 'value>
#[cfg_attr(not(feature = "no-inline"), inline)]
#[must_use]
fn from(v: std::borrow::Cow<'value, str>) -> Self {
Value::Value(Cow::Owned(borrowed::Value::from(v)))
Value::Value(StdCow::Owned(borrowed::Value::from(v)))
}
}

Expand All @@ -52,15 +52,15 @@ impl<'tape, 'value> From<beef::lean::Cow<'value, str>> for Value<'tape, 'value>
#[cfg_attr(not(feature = "no-inline"), inline)]
#[must_use]
fn from(v: beef::lean::Cow<'value, str>) -> Self {
Value::Value(Cow::Owned(borrowed::Value::from(v)))
Value::Value(StdCow::Owned(borrowed::Value::from(v)))
}
}

impl<'tape, 'value> From<String> for Value<'tape, 'value> {
#[cfg_attr(not(feature = "no-inline"), inline)]
#[must_use]
fn from(v: String) -> Self {
Value::Value(Cow::Owned(borrowed::Value::from(v)))
Value::Value(StdCow::Owned(borrowed::Value::from(v)))
}
}

Expand All @@ -69,14 +69,14 @@ impl<'tape, 'value> From<bool> for Value<'tape, 'value> {
#[cfg_attr(not(feature = "no-inline"), inline)]
#[must_use]
fn from(v: bool) -> Self {
Value::Value(Cow::Owned(borrowed::Value::from(v)))
Value::Value(StdCow::Owned(borrowed::Value::from(v)))
}
}
impl<'tape, 'value> From<()> for Value<'tape, 'value> {
#[cfg_attr(not(feature = "no-inline"), inline)]
#[must_use]
fn from(v: ()) -> Self {
Value::Value(Cow::Owned(borrowed::Value::from(v)))
Value::Value(StdCow::Owned(borrowed::Value::from(v)))
}
}

Expand All @@ -85,31 +85,31 @@ impl<'tape, 'value> From<i8> for Value<'tape, 'value> {
#[cfg_attr(not(feature = "no-inline"), inline)]
#[must_use]
fn from(v: i8) -> Self {
Value::Value(Cow::Owned(borrowed::Value::from(v)))
Value::Value(StdCow::Owned(borrowed::Value::from(v)))
}
}

impl<'tape, 'value> From<i16> for Value<'tape, 'value> {
#[cfg_attr(not(feature = "no-inline"), inline)]
#[must_use]
fn from(v: i16) -> Self {
Value::Value(Cow::Owned(borrowed::Value::from(v)))
Value::Value(StdCow::Owned(borrowed::Value::from(v)))
}
}

impl<'tape, 'value> From<i32> for Value<'tape, 'value> {
#[cfg_attr(not(feature = "no-inline"), inline)]
#[must_use]
fn from(v: i32) -> Self {
Value::Value(Cow::Owned(borrowed::Value::from(v)))
Value::Value(StdCow::Owned(borrowed::Value::from(v)))
}
}

impl<'tape, 'value> From<i64> for Value<'tape, 'value> {
#[cfg_attr(not(feature = "no-inline"), inline)]
#[must_use]
fn from(v: i64) -> Self {
Value::Value(Cow::Owned(borrowed::Value::from(v)))
Value::Value(StdCow::Owned(borrowed::Value::from(v)))
}
}

Expand All @@ -118,7 +118,7 @@ impl<'tape, 'value> From<i128> for Value<'tape, 'value> {
#[cfg_attr(not(feature = "no-inline"), inline)]
#[must_use]
fn from(v: i128) -> Self {
Value::Value(Cow::Owned(borrowed::Value::from(v)))
Value::Value(StdCow::Owned(borrowed::Value::from(v)))
}
}

Expand All @@ -127,31 +127,31 @@ impl<'tape, 'value> From<u8> for Value<'tape, 'value> {
#[cfg_attr(not(feature = "no-inline"), inline)]
#[must_use]
fn from(v: u8) -> Self {
Value::Value(Cow::Owned(borrowed::Value::from(v)))
Value::Value(StdCow::Owned(borrowed::Value::from(v)))
}
}

impl<'tape, 'value> From<u16> for Value<'tape, 'value> {
#[cfg_attr(not(feature = "no-inline"), inline)]
#[must_use]
fn from(v: u16) -> Self {
Value::Value(Cow::Owned(borrowed::Value::from(v)))
Value::Value(StdCow::Owned(borrowed::Value::from(v)))
}
}

impl<'tape, 'value> From<u32> for Value<'tape, 'value> {
#[cfg_attr(not(feature = "no-inline"), inline)]
#[must_use]
fn from(v: u32) -> Self {
Value::Value(Cow::Owned(borrowed::Value::from(v)))
Value::Value(StdCow::Owned(borrowed::Value::from(v)))
}
}

impl<'tape, 'value> From<u64> for Value<'tape, 'value> {
#[cfg_attr(not(feature = "no-inline"), inline)]
#[must_use]
fn from(v: u64) -> Self {
Value::Value(Cow::Owned(borrowed::Value::from(v)))
Value::Value(StdCow::Owned(borrowed::Value::from(v)))
}
}

Expand All @@ -160,15 +160,15 @@ impl<'tape, 'value> From<u128> for Value<'tape, 'value> {
#[cfg_attr(not(feature = "no-inline"), inline)]
#[must_use]
fn from(v: u128) -> Self {
Value::Value(Cow::Owned(borrowed::Value::from(v)))
Value::Value(StdCow::Owned(borrowed::Value::from(v)))
}
}

impl<'tape, 'value> From<usize> for Value<'tape, 'value> {
#[cfg_attr(not(feature = "no-inline"), inline)]
#[must_use]
fn from(v: usize) -> Self {
Value::Value(Cow::Owned(borrowed::Value::from(v)))
Value::Value(StdCow::Owned(borrowed::Value::from(v)))
}
}

Expand All @@ -177,15 +177,15 @@ impl<'tape, 'value> From<f32> for Value<'tape, 'value> {
#[cfg_attr(not(feature = "no-inline"), inline)]
#[must_use]
fn from(v: f32) -> Self {
Value::Value(Cow::Owned(borrowed::Value::from(v)))
Value::Value(StdCow::Owned(borrowed::Value::from(v)))
}
}

impl<'tape, 'value> From<f64> for Value<'tape, 'value> {
#[cfg_attr(not(feature = "no-inline"), inline)]
#[must_use]
fn from(v: f64) -> Self {
Value::Value(Cow::Owned(borrowed::Value::from(v)))
Value::Value(StdCow::Owned(borrowed::Value::from(v)))
}
}

Expand All @@ -196,15 +196,15 @@ where
#[cfg_attr(not(feature = "no-inline"), inline)]
#[must_use]
fn from(v: Vec<S>) -> Self {
Value::Value(Cow::Owned(borrowed::Value::from(v)))
Value::Value(StdCow::Owned(borrowed::Value::from(v)))
}
}

impl<'tape, 'value, V: Into<borrowed::Value<'value>>> FromIterator<V> for Value<'tape, 'value> {
#[cfg_attr(not(feature = "no-inline"), inline)]
#[must_use]
fn from_iter<I: IntoIterator<Item = V>>(v: I) -> Self {
Value::Value(Cow::Owned(borrowed::Value::from_iter(v)))
Value::Value(StdCow::Owned(borrowed::Value::from_iter(v)))
}
}

Expand All @@ -214,14 +214,14 @@ impl<'tape, 'value, K: Into<Cow<'value, str>>, V: Into<borrowed::Value<'value>>>
#[cfg_attr(not(feature = "no-inline"), inline)]
#[must_use]
fn from_iter<I: IntoIterator<Item = (K, V)>>(v: I) -> Self {
Value::Value(Cow::Owned(borrowed::Value::from_iter(v)))
Value::Value(StdCow::Owned(borrowed::Value::from_iter(v)))
}
}

impl<'tape, 'value> From<crate::borrowed::Object<'value>> for Value<'tape, 'value> {
#[cfg_attr(not(feature = "no-inline"), inline)]
#[must_use]
fn from(v: crate::borrowed::Object<'value>) -> Self {
Value::Value(Cow::Owned(borrowed::Value::from(v)))
Value::Value(StdCow::Owned(borrowed::Value::from(v)))
}
}
8 changes: 4 additions & 4 deletions src/value/lazy/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@ pub enum Iter<'tape, 'input> {
/// Tape variant
Tape(tape::object::Iter<'tape, 'input>),
/// Value variant
Value(halfbrown::Iter<'tape, Cow<'input, str>, borrowed::Value<'input>>),
Value(halfbrown::Iter<'tape, crate::cow::Cow<'input, str>, borrowed::Value<'input>>),
}
pub enum Keys<'tape, 'input> {
/// Tape variant
Tape(tape::object::Keys<'tape, 'input>),
/// Value variant
Value(halfbrown::Keys<'tape, Cow<'input, str>, borrowed::Value<'input>>),
Value(halfbrown::Keys<'tape, crate::cow::Cow<'input, str>, borrowed::Value<'input>>),
}
pub enum Values<'tape, 'input> {
/// Tape variant
Tape(tape::object::Values<'tape, 'input>),
/// Value variant
Value(halfbrown::Values<'tape, Cow<'input, str>, borrowed::Value<'input>>),
Value(halfbrown::Values<'tape, crate::cow::Cow<'input, str>, borrowed::Value<'input>>),
}

//value_trait::Object for
Expand All @@ -41,7 +41,7 @@ impl<'tape, 'input> Object<'tape, 'input> {
pub fn get<Q>(&self, k: &Q) -> Option<Value<'_, 'input>>
where
str: Borrow<Q>,
std::borrow::Cow<'input, str>: Borrow<Q>,
crate::cow::Cow<'input, str>: Borrow<Q>,
Q: ?Sized + Hash + Eq + Ord,
{
match self {
Expand Down

0 comments on commit 19228a6

Please sign in to comment.