Skip to content

Commit 1281562

Browse files
authored
Merge pull request #241 from epage/message
fix: Rename `Label::ERROR.text().title()` with `Label::ERROR.with_name().title()`
2 parents 5473f87 + ac6423c commit 1281562

File tree

4 files changed

+9
-7
lines changed

4 files changed

+9
-7
lines changed

examples/custom_error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub static C: u32 = 0 - 1;
1717
"#;
1818
let message = &[Group::with_title(
1919
Level::ERROR
20-
.text(Some("error: internal compiler error"))
20+
.with_name(Some("error: internal compiler error"))
2121
.title("could not evaluate static initializer")
2222
.id("E0080"),
2323
)

examples/custom_level.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ fn main() {
5252
),
5353
Group::with_title(
5454
Level::HELP
55-
.text(Some("suggestion"))
55+
.with_name(Some("suggestion"))
5656
.title("use `break` on its own without a value inside this `while` loop"),
5757
)
5858
.element(

src/level.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,18 @@ impl<'a> Level<'a> {
5050
pub const NOTE: Level<'a> = NOTE;
5151
pub const HELP: Level<'a> = HELP;
5252

53+
/// Replace the name describing this [`Level`]
54+
///
5355
/// <div class="warning">
5456
///
5557
/// Text passed to this function is considered "untrusted input", as such
5658
/// all text is passed through a normalization function. Pre-styled text is
5759
/// not allowed to be passed to this function.
5860
///
5961
/// </div>
60-
pub fn text(self, text: impl Into<OptionCow<'a>>) -> Level<'a> {
62+
pub fn with_name(self, name: impl Into<OptionCow<'a>>) -> Level<'a> {
6163
Level {
62-
name: Some(text.into().0),
64+
name: Some(name.into().0),
6365
level: self.level,
6466
}
6567
}

tests/formatter.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2397,7 +2397,7 @@ fn secondary_title_no_level_text() {
23972397
)
23982398
.element(
23992399
Level::NOTE
2400-
.text(None::<&str>)
2400+
.with_name(None::<&str>)
24012401
.title("expected reference `&str`\nfound reference `&'static [u8; 0]`"),
24022402
),
24032403
];
@@ -2442,7 +2442,7 @@ fn secondary_title_custom_level_text() {
24422442
)
24432443
.element(
24442444
Level::NOTE
2445-
.text(Some("custom"))
2445+
.with_name(Some("custom"))
24462446
.title("expected reference `&str`\nfound reference `&'static [u8; 0]`"),
24472447
),
24482448
];
@@ -2515,7 +2515,7 @@ fn main() {
25152515
),
25162516
Group::with_title(
25172517
Level::HELP
2518-
.text(Some("suggestion"))
2518+
.with_name(Some("suggestion"))
25192519
.title("use `break` on its own without a value inside this `while` loop")
25202520
.id("S0123"),
25212521
)

0 commit comments

Comments
 (0)