From 504b54a79a40f64c441b14f6230605d3102232fe Mon Sep 17 00:00:00 2001 From: Ed Page Date: Wed, 2 Jul 2025 09:57:45 -0500 Subject: [PATCH 1/2] docs: Describe Level::text --- src/level.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/level.rs b/src/level.rs index 5934a280..f608a8c9 100644 --- a/src/level.rs +++ b/src/level.rs @@ -50,6 +50,8 @@ impl<'a> Level<'a> { pub const NOTE: Level<'a> = NOTE; pub const HELP: Level<'a> = HELP; + /// Replace the text describing this [`Level`] + /// ///
/// /// Text passed to this function is considered "untrusted input", as such From ac6423c2b488cebf15286c9932d5f0cdb470adc2 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Wed, 2 Jul 2025 10:01:12 -0500 Subject: [PATCH 2/2] fix: Rename `Label::ERROR.text().title()` with `Label::ERROR.with_name().title()` --- examples/custom_error.rs | 2 +- examples/custom_level.rs | 2 +- src/level.rs | 6 +++--- tests/formatter.rs | 6 +++--- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/examples/custom_error.rs b/examples/custom_error.rs index 76ae0cce..dde6e3f3 100644 --- a/examples/custom_error.rs +++ b/examples/custom_error.rs @@ -17,7 +17,7 @@ pub static C: u32 = 0 - 1; "#; let message = &[Group::with_title( Level::ERROR - .text(Some("error: internal compiler error")) + .with_name(Some("error: internal compiler error")) .title("could not evaluate static initializer") .id("E0080"), ) diff --git a/examples/custom_level.rs b/examples/custom_level.rs index 41e8322f..97ec9ab3 100644 --- a/examples/custom_level.rs +++ b/examples/custom_level.rs @@ -52,7 +52,7 @@ fn main() { ), Group::with_title( Level::HELP - .text(Some("suggestion")) + .with_name(Some("suggestion")) .title("use `break` on its own without a value inside this `while` loop"), ) .element( diff --git a/src/level.rs b/src/level.rs index f608a8c9..a068e0f9 100644 --- a/src/level.rs +++ b/src/level.rs @@ -50,7 +50,7 @@ impl<'a> Level<'a> { pub const NOTE: Level<'a> = NOTE; pub const HELP: Level<'a> = HELP; - /// Replace the text describing this [`Level`] + /// Replace the name describing this [`Level`] /// ///
/// @@ -59,9 +59,9 @@ impl<'a> Level<'a> { /// not allowed to be passed to this function. /// ///
- pub fn text(self, text: impl Into>) -> Level<'a> { + pub fn with_name(self, name: impl Into>) -> Level<'a> { Level { - name: Some(text.into().0), + name: Some(name.into().0), level: self.level, } } diff --git a/tests/formatter.rs b/tests/formatter.rs index 2c109577..7968a9e8 100644 --- a/tests/formatter.rs +++ b/tests/formatter.rs @@ -2397,7 +2397,7 @@ fn secondary_title_no_level_text() { ) .element( Level::NOTE - .text(None::<&str>) + .with_name(None::<&str>) .title("expected reference `&str`\nfound reference `&'static [u8; 0]`"), ), ]; @@ -2442,7 +2442,7 @@ fn secondary_title_custom_level_text() { ) .element( Level::NOTE - .text(Some("custom")) + .with_name(Some("custom")) .title("expected reference `&str`\nfound reference `&'static [u8; 0]`"), ), ]; @@ -2515,7 +2515,7 @@ fn main() { ), Group::with_title( Level::HELP - .text(Some("suggestion")) + .with_name(Some("suggestion")) .title("use `break` on its own without a value inside this `while` loop") .id("S0123"), )