Skip to content

Commit be82af2

Browse files
author
David Orchard
committed
Rename MapImpl to Map
1 parent 0e0ae2b commit be82af2

40 files changed

+121
-121
lines changed

examples/async_source/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::error::Error;
22

3-
use config::{builder::AsyncState, AsyncSource, ConfigBuilder, ConfigError, FileFormat, MapImpl};
3+
use config::{builder::AsyncState, AsyncSource, ConfigBuilder, ConfigError, FileFormat, Map};
44

55
use async_trait::async_trait;
66
use futures::{select, FutureExt};
@@ -56,7 +56,7 @@ struct HttpSource {
5656

5757
#[async_trait]
5858
impl AsyncSource for HttpSource {
59-
async fn collect(&self) -> Result<MapImpl<String, config::Value>, ConfigError> {
59+
async fn collect(&self) -> Result<Map<String, config::Value>, ConfigError> {
6060
reqwest::get(&self.uri)
6161
.await
6262
.map_err(|e| ConfigError::Foreign(Box::new(e)))? // error conversion is possible from custom AsyncSource impls

examples/glob/src/main.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use std::path::Path;
2-
use std::collections::MapImpl;
2+
use std::collections::Map;
33
use config::*;
44
use glob::glob;
55

@@ -14,9 +14,9 @@ fn main() {
1414
.merge(File::from(Path::new("conf/05-some.yml"))).unwrap()
1515
.merge(File::from(Path::new("conf/99-extra.json"))).unwrap();
1616

17-
// Print out our settings (as a MapImpl)
17+
// Print out our settings (as a Map)
1818
println!("\n{:?} \n\n-----------",
19-
settings.try_into::<MapImpl<String, String>>().unwrap());
19+
settings.try_into::<Map<String, String>>().unwrap());
2020

2121
// Option 2
2222
// --------
@@ -28,9 +28,9 @@ fn main() {
2828
File::from(Path::new("conf/99-extra.json"))])
2929
.unwrap();
3030

31-
// Print out our settings (as a MapImpl)
31+
// Print out our settings (as a Map)
3232
println!("\n{:?} \n\n-----------",
33-
settings.try_into::<MapImpl<String, String>>().unwrap());
33+
settings.try_into::<Map<String, String>>().unwrap());
3434

3535
// Option 3
3636
// --------
@@ -43,7 +43,7 @@ fn main() {
4343
.collect::<Vec<_>>())
4444
.unwrap();
4545

46-
// Print out our settings (as a MapImpl)
46+
// Print out our settings (as a Map)
4747
println!("\n{:?} \n\n-----------",
48-
settings.try_into::<MapImpl<String, String>>().unwrap());
48+
settings.try_into::<Map<String, String>>().unwrap());
4949
}

examples/simple/src/main.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::collections::MapImpl;
1+
use std::collections::Map;
22

33
fn main() {
44
let mut settings = config::Config::default();
@@ -9,7 +9,7 @@ fn main() {
99
// Eg.. `APP_DEBUG=1 ./target/app` would set the `debug` key
1010
.merge(config::Environment::with_prefix("APP")).unwrap();
1111

12-
// Print out our settings (as a MapImpl)
12+
// Print out our settings (as a Map)
1313
println!("{:?}",
14-
settings.try_into::<MapImpl<String, String>>().unwrap());
14+
settings.try_into::<Map<String, String>>().unwrap());
1515
}

examples/watch/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use config::*;
2-
use std::collections::MapImpl;
2+
use std::collections::Map;
33
use std::sync::RwLock;
44
use notify::{RecommendedWatcher, DebouncedEvent, Watcher, RecursiveMode};
55
use std::sync::mpsc::channel;
@@ -20,7 +20,7 @@ fn show() {
2020
.read()
2121
.unwrap()
2222
.clone()
23-
.try_into::<MapImpl<String, String>>()
23+
.try_into::<Map<String, String>>()
2424
.unwrap());
2525
}
2626

src/builder.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::iter::IntoIterator;
22
use std::str::FromStr;
33

44
use crate::error::Result;
5-
use crate::map::MapImpl;
5+
use crate::map::Map;
66
use crate::source::AsyncSource;
77
use crate::{config::Config, path::Expression, source::Source, value::Value};
88

@@ -88,8 +88,8 @@ use crate::{config::Config, path::Expression, source::Source, value::Value};
8888
/// ```
8989
#[derive(Debug, Clone, Default)]
9090
pub struct ConfigBuilder<St: BuilderState> {
91-
defaults: MapImpl<Expression, Value>,
92-
overrides: MapImpl<Expression, Value>,
91+
defaults: Map<Expression, Value>,
92+
overrides: Map<Expression, Value>,
9393
state: St,
9494
}
9595

@@ -121,8 +121,8 @@ pub struct DefaultState {
121121
/// Refer to [`ConfigBuilder`] for similar API sample usage or to the examples folder of the crate, where such a source is implemented.
122122
#[derive(Debug, Clone, Default)]
123123
pub struct AsyncConfigBuilder {
124-
defaults: MapImpl<Expression, Value>,
125-
overrides: MapImpl<Expression, Value>,
124+
defaults: Map<Expression, Value>,
125+
overrides: Map<Expression, Value>,
126126
sources: Vec<SourceType>,
127127
}
128128

@@ -245,11 +245,11 @@ impl ConfigBuilder<DefaultState> {
245245
}
246246

247247
fn build_internal(
248-
defaults: MapImpl<Expression, Value>,
249-
overrides: MapImpl<Expression, Value>,
248+
defaults: Map<Expression, Value>,
249+
overrides: Map<Expression, Value>,
250250
sources: &[Box<dyn Source + Send + Sync>],
251251
) -> Result<Config> {
252-
let mut cache: Value = MapImpl::<String, Value>::new().into();
252+
let mut cache: Value = Map::<String, Value>::new().into();
253253

254254
// Add defaults
255255
for (key, val) in defaults.into_iter() {
@@ -323,11 +323,11 @@ impl ConfigBuilder<AsyncState> {
323323
}
324324

325325
async fn build_internal(
326-
defaults: MapImpl<Expression, Value>,
327-
overrides: MapImpl<Expression, Value>,
326+
defaults: Map<Expression, Value>,
327+
overrides: Map<Expression, Value>,
328328
sources: &[SourceType],
329329
) -> Result<Config> {
330-
let mut cache: Value = MapImpl::<String, Value>::new().into();
330+
let mut cache: Value = Map::<String, Value>::new().into();
331331

332332
// Add defaults
333333
for (key, val) in defaults.into_iter() {

src/config.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use serde::de::Deserialize;
55
use serde::ser::Serialize;
66

77
use crate::error::*;
8-
use crate::map::MapImpl;
8+
use crate::map::Map;
99
use crate::path;
1010
use crate::ser::ConfigSerializer;
1111
use crate::source::Source;
@@ -16,8 +16,8 @@ use crate::value::{Table, Value};
1616
/// them according to the source's priority.
1717
#[derive(Clone, Debug)]
1818
pub struct Config {
19-
defaults: MapImpl<path::Expression, Value>,
20-
overrides: MapImpl<path::Expression, Value>,
19+
defaults: Map<path::Expression, Value>,
20+
overrides: Map<path::Expression, Value>,
2121
sources: Vec<Box<dyn Source + Send + Sync>>,
2222

2323
/// Root of the cached configuration.
@@ -83,7 +83,7 @@ impl Config {
8383
#[deprecated(since = "0.12.0", note = "please use 'ConfigBuilder' instead")]
8484
pub fn refresh(&mut self) -> Result<&mut Config> {
8585
self.cache = {
86-
let mut cache: Value = MapImpl::<String, Value>::new().into();
86+
let mut cache: Value = Map::<String, Value>::new().into();
8787

8888
// Add defaults
8989
for (key, val) in self.defaults.iter() {
@@ -181,7 +181,7 @@ impl Config {
181181
self.get(key).and_then(Value::into_bool)
182182
}
183183

184-
pub fn get_table(&self, key: &str) -> Result<MapImpl<String, Value>> {
184+
pub fn get_table(&self, key: &str) -> Result<Map<String, Value>> {
185185
self.get(key).and_then(Value::into_table)
186186
}
187187

@@ -212,7 +212,7 @@ impl Source for Config {
212212
Box::new((*self).clone())
213213
}
214214

215-
fn collect(&self) -> Result<MapImpl<String, Value>> {
215+
fn collect(&self) -> Result<Map<String, Value>> {
216216
self.cache.clone().into_table()
217217
}
218218
}

src/de.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use serde::de;
55

66
use crate::config::Config;
77
use crate::error::*;
8-
use crate::map::MapImpl;
8+
use crate::map::Map;
99
use crate::value::{Table, Value, ValueKind};
1010

1111
impl<'de> de::Deserializer<'de> for Value {
@@ -200,7 +200,7 @@ struct MapAccess {
200200
}
201201

202202
impl MapAccess {
203-
fn new(table: MapImpl<String, Value>) -> Self {
203+
fn new(table: Map<String, Value>) -> Self {
204204
MapAccess {
205205
elements: table.into_iter().collect(),
206206
}

src/env.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::env;
22

33
use crate::error::*;
4-
use crate::map::MapImpl;
4+
use crate::map::Map;
55
use crate::source::Source;
66
use crate::value::{Value, ValueKind};
77

@@ -79,8 +79,8 @@ impl Source for Environment {
7979
Box::new((*self).clone())
8080
}
8181

82-
fn collect(&self) -> Result<MapImpl<String, Value>> {
83-
let mut m = MapImpl::new();
82+
fn collect(&self) -> Result<Map<String, Value>> {
83+
let mut m = Map::new();
8484
let uri: String = "the environment".into();
8585

8686
let separator = self.separator.as_deref().unwrap_or("");

src/file/format/hjson.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
use std::error::Error;
22

3-
use crate::map::MapImpl;
3+
use crate::map::Map;
44
use crate::value::{Value, ValueKind};
55

66
pub fn parse(
77
uri: Option<&String>,
88
text: &str,
9-
) -> Result<MapImpl<String, Value>, Box<dyn Error + Send + Sync>> {
9+
) -> Result<Map<String, Value>, Box<dyn Error + Send + Sync>> {
1010
// Parse a JSON object value from the text
1111
// TODO: Have a proper error fire if the root of a file is ever not a Table
1212
let value = from_hjson_value(uri, &serde_hjson::from_str(text)?);
1313
match value.kind {
1414
ValueKind::Table(map) => Ok(map),
1515

16-
_ => Ok(MapImpl::new()),
16+
_ => Ok(Map::new()),
1717
}
1818
}
1919

@@ -30,7 +30,7 @@ fn from_hjson_value(uri: Option<&String>, value: &serde_hjson::Value) -> Value {
3030
serde_hjson::Value::Bool(value) => Value::new(uri, ValueKind::Boolean(value)),
3131

3232
serde_hjson::Value::Object(ref table) => {
33-
let mut m = MapImpl::new();
33+
let mut m = Map::new();
3434

3535
for (key, value) in table {
3636
m.insert(key.clone(), from_hjson_value(uri, value));

src/file/format/ini.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@ use std::error::Error;
22

33
use ini::Ini;
44

5-
use crate::map::MapImpl;
5+
use crate::map::Map;
66
use crate::value::{Value, ValueKind};
77

88
pub fn parse(
99
uri: Option<&String>,
1010
text: &str,
11-
) -> Result<MapImpl<String, Value>, Box<dyn Error + Send + Sync>> {
12-
let mut map: MapImpl<String, Value> = MapImpl::new();
11+
) -> Result<Map<String, Value>, Box<dyn Error + Send + Sync>> {
12+
let mut map: Map<String, Value> = Map::new();
1313
let i = Ini::load_from_str(text)?;
1414
for (sec, prop) in i.iter() {
1515
match sec {
1616
Some(sec) => {
17-
let mut sec_map: MapImpl<String, Value> = MapImpl::new();
17+
let mut sec_map: Map<String, Value> = Map::new();
1818
for (k, v) in prop.iter() {
1919
sec_map.insert(
2020
k.to_owned(),

0 commit comments

Comments
 (0)