diff options
Diffstat (limited to 'src/lib.rs')
-rw-r--r-- | src/lib.rs | 7 |
1 files changed, 6 insertions, 1 deletions
@@ -14,6 +14,9 @@ use alloc::{format, vec}; use core::fmt; use core::mem::take; +#[cfg(test)] +mod tests; + /// File and line information #[derive(Clone, Debug)] pub struct Location { @@ -635,6 +638,8 @@ impl Configuration { /// /// `reader` can be `&str`, `&[u8]`, or anything that implements [`std::io::BufRead`] /// (if the `std` feature is enabled) such as `std::io::BufReader<std::fs::File>`. + /// + /// `filename` is used in error messages. pub fn load<R: Read>(filename: &str, mut reader: R) -> Result<Self> { // avoid big code size by using dyn reference. // the impact on performance is not really important. @@ -717,7 +722,7 @@ impl Configuration { pub fn subkeys(&self, key: &str) -> impl '_ + Iterator<Item = &str> { let key_dot = format!("{key}."); let start_idx = self.first_subkey_index(key); - (start_idx..).map_while(move |i| { + (start_idx..self.items.len()).map_while(move |i| { let this_key = &self.items[i].0; let suffix = this_key.strip_prefix(&key_dot)?; Some(suffix.split_once('.').map_or(suffix, |(x, _)| x)) |