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

Use less confusing terminology for string parts in DiagnosticPath #11559

Closed
wants to merge 1 commit into from
Closed
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
16 changes: 8 additions & 8 deletions crates/bevy_diagnostic/src/diagnostic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use crate::DEFAULT_MAX_HISTORY_LENGTH;
/// Requirements:
/// - Can't be empty
/// - Can't have leading or trailing `/`
/// - Can't have empty components.
/// - Can't have empty sections.
#[derive(Debug, Clone)]
pub struct DiagnosticPath {
path: Cow<'static, str>,
Expand Down Expand Up @@ -46,7 +46,7 @@ impl DiagnosticPath {
);
debug_assert!(
!path.contains("//"),
"diagnostic path can't contain empty components"
"diagnostic path can't contain empty sections"
);

DiagnosticPath {
Expand All @@ -55,15 +55,15 @@ impl DiagnosticPath {
}
}

/// Create a new `DiagnosticPath` from an iterator over components.
pub fn from_components<'a>(components: impl IntoIterator<Item = &'a str>) -> DiagnosticPath {
/// Create a new `DiagnosticPath` from an iterator over sections.
pub fn from_sections<'a>(sections: impl IntoIterator<Item = &'a str>) -> DiagnosticPath {
let mut buf = String::new();

for (i, component) in components.into_iter().enumerate() {
for (i, section) in sections.into_iter().enumerate() {
if i > 0 {
buf.push('/');
}
buf.push_str(component);
buf.push_str(section);
}

DiagnosticPath::new(buf)
Expand All @@ -74,8 +74,8 @@ impl DiagnosticPath {
&self.path
}

/// Returns an iterator over path components.
pub fn components(&self) -> impl Iterator<Item = &str> + '_ {
/// Returns an iterator over path sections.
pub fn sections(&self) -> impl Iterator<Item = &str> + '_ {
self.path.split('/')
}
}
Expand Down
Loading