Skip to content

Commit

Permalink
Showing 9 changed files with 37 additions and 20 deletions.
6 changes: 4 additions & 2 deletions crates/toml_edit/src/array.rs
Original file line number Diff line number Diff line change
@@ -87,8 +87,10 @@ impl Array {
&self.decor
}

/// Returns the location within the original document
pub(crate) fn span(&self) -> Option<std::ops::Range<usize>> {
/// The location within the original document
///
/// This generally requires an [`ImDocument`][crate::ImDocument].
pub fn span(&self) -> Option<std::ops::Range<usize>> {
self.span.clone()
}

6 changes: 4 additions & 2 deletions crates/toml_edit/src/array_of_tables.rs
Original file line number Diff line number Diff line change
@@ -32,8 +32,10 @@ impl ArrayOfTables {
a
}

/// Returns the location within the original document
pub(crate) fn span(&self) -> Option<std::ops::Range<usize>> {
/// The location within the original document
///
/// This generally requires an [`ImDocument`][crate::ImDocument].
pub fn span(&self) -> Option<std::ops::Range<usize>> {
self.span.clone()
}

6 changes: 4 additions & 2 deletions crates/toml_edit/src/inline_table.rs
Original file line number Diff line number Diff line change
@@ -219,8 +219,10 @@ impl InlineTable {
&self.preamble
}

/// Returns the location within the original document
pub(crate) fn span(&self) -> Option<std::ops::Range<usize>> {
/// The location within the original document
///
/// This generally requires an [`ImDocument`][crate::ImDocument].
pub fn span(&self) -> Option<std::ops::Range<usize>> {
self.span.clone()
}

6 changes: 4 additions & 2 deletions crates/toml_edit/src/item.rs
Original file line number Diff line number Diff line change
@@ -297,8 +297,10 @@ impl Item {
self.as_table_like().is_some()
}

/// Returns the location within the original document
pub(crate) fn span(&self) -> Option<std::ops::Range<usize>> {
/// The location within the original document
///
/// This generally requires an [`ImDocument`][crate::ImDocument].
pub fn span(&self) -> Option<std::ops::Range<usize>> {
match self {
Item::None => None,
Item::Value(v) => v.span(),
7 changes: 4 additions & 3 deletions crates/toml_edit/src/key.rs
Original file line number Diff line number Diff line change
@@ -147,9 +147,10 @@ impl Key {
&self.dotted_decor
}

/// Returns the location within the original document
#[cfg(feature = "serde")]
pub(crate) fn span(&self) -> Option<std::ops::Range<usize>> {
/// The location within the original document
///
/// This generally requires an [`ImDocument`][crate::ImDocument].
pub fn span(&self) -> Option<std::ops::Range<usize>> {
self.repr.as_ref().and_then(|r| r.span())
}

2 changes: 1 addition & 1 deletion crates/toml_edit/src/raw_string.rs
Original file line number Diff line number Diff line change
@@ -31,7 +31,7 @@ impl RawString {
}
}

/// Access the underlying span
/// The location within the original document
///
/// This generally requires an [`ImDocument`][crate::ImDocument].
pub fn span(&self) -> Option<std::ops::Range<usize>> {
12 changes: 8 additions & 4 deletions crates/toml_edit/src/repr.rs
Original file line number Diff line number Diff line change
@@ -60,8 +60,10 @@ where
})
}

/// Returns the location within the original document
pub(crate) fn span(&self) -> Option<std::ops::Range<usize>> {
/// The location within the original document
///
/// This generally requires an [`ImDocument`][crate::ImDocument].
pub fn span(&self) -> Option<std::ops::Range<usize>> {
self.repr.as_ref().and_then(|r| r.span())
}

@@ -150,8 +152,10 @@ impl Repr {
&self.raw_value
}

/// Returns the location within the original document
pub(crate) fn span(&self) -> Option<std::ops::Range<usize>> {
/// The location within the original document
///
/// This generally requires an [`ImDocument`][crate::ImDocument].
pub fn span(&self) -> Option<std::ops::Range<usize>> {
self.raw_value.span()
}

6 changes: 4 additions & 2 deletions crates/toml_edit/src/table.rs
Original file line number Diff line number Diff line change
@@ -242,8 +242,10 @@ impl Table {
self.items.get(key).map(|kv| kv.key.leaf_decor())
}

/// Returns the location within the original document
pub(crate) fn span(&self) -> Option<std::ops::Range<usize>> {
/// The location within the original document
///
/// This generally requires an [`ImDocument`][crate::ImDocument].
pub fn span(&self) -> Option<std::ops::Range<usize>> {
self.span.clone()
}

6 changes: 4 additions & 2 deletions crates/toml_edit/src/value.rs
Original file line number Diff line number Diff line change
@@ -206,8 +206,10 @@ impl Value {
*decor = Decor::new(prefix, suffix);
}

/// Returns the location within the original document
pub(crate) fn span(&self) -> Option<std::ops::Range<usize>> {
/// The location within the original document
///
/// This generally requires an [`ImDocument`][crate::ImDocument].
pub fn span(&self) -> Option<std::ops::Range<usize>> {
match self {
Value::String(f) => f.span(),
Value::Integer(f) => f.span(),

0 comments on commit ddb5bf0

Please sign in to comment.