Skip to content

Commit

Permalink
Merge pull request #678 from epage/key
Browse files Browse the repository at this point in the history
fix(edit): Support more types of tables for key fn
  • Loading branch information
epage committed Feb 6, 2024
2 parents 8fa5a60 + 069f404 commit f345c8c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions crates/toml_edit/src/inline_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ impl InlineTable {
}

/// Returns an accessor to a key's formatting
pub fn key(&mut self, key: &str) -> Option<&'_ Key> {
pub fn key(&self, key: &str) -> Option<&'_ Key> {
self.items.get(key).map(|kv| &kv.key)
}

Expand Down Expand Up @@ -578,7 +578,7 @@ impl TableLike for InlineTable {
self.is_dotted()
}

fn key(&mut self, key: &str) -> Option<&'_ Key> {
fn key(&self, key: &str) -> Option<&'_ Key> {
self.key(key)
}
fn key_mut(&mut self, key: &str) -> Option<KeyMut<'_>> {
Expand Down
6 changes: 3 additions & 3 deletions crates/toml_edit/src/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ impl Table {
}

/// Returns an accessor to a key's formatting
pub fn key(&mut self, key: &str) -> Option<&'_ Key> {
pub fn key(&self, key: &str) -> Option<&'_ Key> {
self.items.get(key).map(|kv| &kv.key)
}

Expand Down Expand Up @@ -577,7 +577,7 @@ pub trait TableLike: crate::private::Sealed {
fn is_dotted(&self) -> bool;

/// Returns an accessor to a key's formatting
fn key(&mut self, key: &str) -> Option<&'_ Key>;
fn key(&self, key: &str) -> Option<&'_ Key>;
/// Returns an accessor to a key's formatting
fn key_mut(&mut self, key: &str) -> Option<KeyMut<'_>>;
/// Returns the decor associated with a given key of the table.
Expand Down Expand Up @@ -642,7 +642,7 @@ impl TableLike for Table {
self.set_dotted(yes)
}

fn key(&mut self, key: &str) -> Option<&'_ Key> {
fn key(&self, key: &str) -> Option<&'_ Key> {
self.key(key)
}
fn key_mut(&mut self, key: &str) -> Option<KeyMut<'_>> {
Expand Down

0 comments on commit f345c8c

Please sign in to comment.