Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(edit): Support more types of tables for key fn #678

Merged
merged 1 commit into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading