diff options
author | Federico Pasqua <federico.pasqua.96@gmail.com> | 2020-03-14 15:46:36 +0100 |
---|---|---|
committer | Federico Pasqua <federico.pasqua.96@gmail.com> | 2020-03-14 16:01:54 +0100 |
commit | 57fb2610ad274dff1d2f2e4d43dfce05ca9c4835 (patch) | |
tree | 45e4c5c57df0eea23e8977de0984965d9a8a56b4 /src/file | |
parent | 2c0b201055be60ec45e258adcc6c4b6e01bcd627 (diff) |
General upgrade for clippy fix and remove of deprecated methods for errors
Diffstat (limited to 'src/file')
-rw-r--r-- | src/file/format/hjson.rs | 2 | ||||
-rw-r--r-- | src/file/format/ini.rs | 2 | ||||
-rw-r--r-- | src/file/format/json.rs | 2 | ||||
-rw-r--r-- | src/file/format/mod.rs | 10 | ||||
-rw-r--r-- | src/file/format/toml.rs | 2 | ||||
-rw-r--r-- | src/file/format/yaml.rs | 2 | ||||
-rw-r--r-- | src/file/mod.rs | 6 | ||||
-rw-r--r-- | src/file/source/file.rs | 8 | ||||
-rw-r--r-- | src/file/source/mod.rs | 2 | ||||
-rw-r--r-- | src/file/source/string.rs | 2 |
10 files changed, 19 insertions, 19 deletions
diff --git a/src/file/format/hjson.rs b/src/file/format/hjson.rs index cb0a064..457cfbf 100644 --- a/src/file/format/hjson.rs +++ b/src/file/format/hjson.rs @@ -7,7 +7,7 @@ use value::{Value, ValueKind}; pub fn parse( uri: Option<&String>, text: &str, -) -> Result<HashMap<String, Value>, Box<Error + Send + Sync>> { +) -> Result<HashMap<String, Value>, Box<dyn Error + Send + Sync>> { // Parse a JSON object value from the text // TODO: Have a proper error fire if the root of a file is ever not a Table let value = from_hjson_value(uri, &serde_hjson::from_str(text)?); diff --git a/src/file/format/ini.rs b/src/file/format/ini.rs index 845de3a..e5e5950 100644 --- a/src/file/format/ini.rs +++ b/src/file/format/ini.rs @@ -7,7 +7,7 @@ use value::{Value, ValueKind}; pub fn parse( uri: Option<&String>, text: &str, -) -> Result<HashMap<String, Value>, Box<Error + Send + Sync>> { +) -> Result<HashMap<String, Value>, Box<dyn Error + Send + Sync>> { let mut map: HashMap<String, Value> = HashMap::new(); let i = Ini::load_from_str(text)?; for (sec, prop) in i.iter() { diff --git a/src/file/format/json.rs b/src/file/format/json.rs index 87240a3..0d15070 100644 --- a/src/file/format/json.rs +++ b/src/file/format/json.rs @@ -7,7 +7,7 @@ use value::{Value, ValueKind}; pub fn parse( uri: Option<&String>, text: &str, -) -> Result<HashMap<String, Value>, Box<Error + Send + Sync>> { +) -> Result<HashMap<String, Value>, Box<dyn Error + Send + Sync>> { // Parse a JSON object value from the text // TODO: Have a proper error fire if the root of a file is ever not a Table let value = from_json_value(uri, &serde_json::from_str(text)?); diff --git a/src/file/format/mod.rs b/src/file/format/mod.rs index 39b3813..f46ae13 100644 --- a/src/file/format/mod.rs +++ b/src/file/format/mod.rs @@ -72,22 +72,22 @@ lazy_static! { impl FileFormat { // TODO: pub(crate) #[doc(hidden)] - pub fn extensions(&self) -> &'static Vec<&'static str> { + pub fn extensions(self) -> &'static Vec<&'static str> { // It should not be possible for this to fail // A FileFormat would need to be declared without being added to the // ALL_EXTENSIONS map. - ALL_EXTENSIONS.get(self).unwrap() + ALL_EXTENSIONS.get(&self).unwrap() } // TODO: pub(crate) #[doc(hidden)] #[allow(unused_variables)] pub fn parse( - &self, + self, uri: Option<&String>, text: &str, - ) -> Result<HashMap<String, Value>, Box<Error + Send + Sync>> { - match *self { + ) -> Result<HashMap<String, Value>, Box<dyn Error + Send + Sync>> { + match self { #[cfg(feature = "toml")] FileFormat::Toml => toml::parse(uri, text), diff --git a/src/file/format/toml.rs b/src/file/format/toml.rs index 26dcb2a..a40104e 100644 --- a/src/file/format/toml.rs +++ b/src/file/format/toml.rs @@ -7,7 +7,7 @@ use value::{Value, ValueKind}; pub fn parse( uri: Option<&String>, text: &str, -) -> Result<HashMap<String, Value>, Box<Error + Send + Sync>> { +) -> Result<HashMap<String, Value>, Box<dyn Error + Send + Sync>> { // Parse a TOML value from the provided text // TODO: Have a proper error fire if the root of a file is ever not a Table let value = from_toml_value(uri, &toml::from_str(text)?); diff --git a/src/file/format/yaml.rs b/src/file/format/yaml.rs index c2b26cb..c458c3c 100644 --- a/src/file/format/yaml.rs +++ b/src/file/format/yaml.rs @@ -9,7 +9,7 @@ use yaml_rust as yaml; pub fn parse( uri: Option<&String>, text: &str, -) -> Result<HashMap<String, Value>, Box<Error + Send + Sync>> { +) -> Result<HashMap<String, Value>, Box<dyn Error + Send + Sync>> { // Parse a YAML object from file let mut docs = yaml::YamlLoader::load_from_str(text)?; let root = match docs.len() { diff --git a/src/file/mod.rs b/src/file/mod.rs index 342d09b..ebe93bc 100644 --- a/src/file/mod.rs +++ b/src/file/mod.rs @@ -94,7 +94,7 @@ where T: 'static, T: Sync + Send, { - fn clone_into_box(&self) -> Box<Source + Send + Sync> { + fn clone_into_box(&self) -> Box<dyn Source + Send + Sync> { Box::new((*self).clone()) } @@ -120,8 +120,8 @@ where format .parse(uri.as_ref(), &contents) .map_err(|cause| ConfigError::FileParse { - uri: uri, - cause: cause, + uri, + cause, }) } } diff --git a/src/file/source/file.rs b/src/file/source/file.rs index a413a1f..57c251f 100644 --- a/src/file/source/file.rs +++ b/src/file/source/file.rs @@ -21,13 +21,13 @@ pub struct FileSourceFile { impl FileSourceFile { pub fn new(name: PathBuf) -> FileSourceFile { - FileSourceFile { name: name } + FileSourceFile { name } } fn find_file( &self, format_hint: Option<FileFormat>, - ) -> Result<(PathBuf, FileFormat), Box<Error + Send + Sync>> { + ) -> Result<(PathBuf, FileFormat), Box<dyn Error + Send + Sync>> { // First check for an _exact_ match let mut filename = env::current_dir()?.as_path().join(self.name.clone()); if filename.is_file() { @@ -91,7 +91,7 @@ impl FileSource for FileSourceFile { fn resolve( &self, format_hint: Option<FileFormat>, - ) -> Result<(Option<String>, String, FileFormat), Box<Error + Send + Sync>> { + ) -> Result<(Option<String>, String, FileFormat), Box<dyn Error + Send + Sync>> { // Find file let (filename, format) = self.find_file(format_hint)?; @@ -103,7 +103,7 @@ impl FileSource for FileSourceFile { }; // Read contents from file - let mut file = fs::File::open(filename.clone())?; + let mut file = fs::File::open(filename)?; let mut text = String::new(); file.read_to_string(&mut text)?; diff --git a/src/file/source/mod.rs b/src/file/source/mod.rs index 5da69f1..ab276d0 100644 --- a/src/file/source/mod.rs +++ b/src/file/source/mod.rs @@ -12,5 +12,5 @@ pub trait FileSource: Debug + Clone { fn resolve( &self, format_hint: Option<FileFormat>, - ) -> Result<(Option<String>, String, FileFormat), Box<Error + Send + Sync>>; + ) -> Result<(Option<String>, String, FileFormat), Box<dyn Error + Send + Sync>>; } diff --git a/src/file/source/string.rs b/src/file/source/string.rs index a2f66cb..3896cce 100644 --- a/src/file/source/string.rs +++ b/src/file/source/string.rs @@ -19,7 +19,7 @@ impl FileSource for FileSourceString { fn resolve( &self, format_hint: Option<FileFormat>, - ) -> Result<(Option<String>, String, FileFormat), Box<Error + Send + Sync>> { + ) -> Result<(Option<String>, String, FileFormat), Box<dyn Error + Send + Sync>> { Ok(( None, self.0.clone(), |