Fix new clippy warnings (#2760)

* Fix new clippy warnings

* Fork serde-hjson and bring in

* Fork serde-hjson and bring in

* Fix clippy lint again
This commit is contained in:
Jonathan Turner
2020-11-22 13:37:16 +13:00
committed by GitHub
parent 63d4df9810
commit 930f9f0063
36 changed files with 5176 additions and 952 deletions

View File

@ -3,7 +3,6 @@ use std::cmp::Ordering;
use std::hash::Hash;
use std::hash::Hasher;
use std::ops::Range;
use std::sync::Arc;
/// A "Text" is like a string except that it can be cheaply cloned.
/// You can also "extract" subtexts quite cheaply. You can also deref
@ -12,7 +11,7 @@ use std::sync::Arc;
/// Used to represent the value of an input file.
#[derive(Clone)]
pub struct Text {
text: Arc<String>,
text: String,
start: usize,
end: usize,
}
@ -39,11 +38,11 @@ impl Text {
}
}
impl From<Arc<String>> for Text {
fn from(text: Arc<String>) -> Self {
impl From<&str> for Text {
fn from(text: &str) -> Self {
let end = text.len();
Self {
text,
text: text.to_string(),
start: 0,
end,
}
@ -58,19 +57,12 @@ impl AsRef<str> for Text {
impl From<String> for Text {
fn from(text: String) -> Self {
Text::from(Arc::new(text))
}
}
impl From<&String> for Text {
fn from(text: &String) -> Self {
Text::from(text.to_string())
}
}
impl From<&str> for Text {
fn from(text: &str) -> Self {
Text::from(text.to_string())
let end = text.len();
Self {
text,
start: 0,
end,
}
}
}