summaryrefslogtreecommitdiff
path: root/src/lib.rs
diff options
context:
space:
mode:
authorpommicket <pommicket@gmail.com>2025-09-08 17:46:54 -0400
committerpommicket <pommicket@gmail.com>2025-09-08 17:46:54 -0400
commite588e013bed4e5c30aa5f605cc0973976e542258 (patch)
treebcad849a69e3b373f2554f494b110f034e08fdb4 /src/lib.rs
parent1632f44e99d8819b0fd5a279ec93f5601c8a7b06 (diff)
Fix subkeys, write comparison test
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/lib.rs b/src/lib.rs
index bd01f59..dc29621 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -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))