Skip to content

Commit c0bc639

Browse files
paolobarbolinijannschu
authored andcommitted
Upgrade thiserror to v2
1 parent 1baca09 commit c0bc639

File tree

2 files changed

+12
-17
lines changed

2 files changed

+12
-17
lines changed

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ keywords = ["code128", "barcode"]
1212

1313
[features]
1414
default = ["std", "unicode"]
15-
std = ["dep:thiserror"]
15+
std = ["thiserror/std"]
1616
unicode = []
1717

1818
[dependencies]
19-
thiserror = { version = "1.0.40", optional = true }
19+
thiserror = { version = "2.0.0", default-features = false }
2020

2121
[dev-dependencies]
2222
atty = "0.2.14"

src/decode.rs

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,44 +2,39 @@ use crate::std::string::String;
22
use crate::std::vec;
33
use crate::std::vec::Vec;
44

5-
#[cfg(feature = "std")]
65
use thiserror::Error;
76

87
use crate::Bar;
98

109
/// Errors that can occur during decoding.
11-
#[derive(Debug, PartialEq)]
12-
#[cfg_attr(feature = "std", derive(Error))]
10+
#[derive(Debug, PartialEq, Error)]
1311
pub enum DecodingError {
1412
/// A sequence of modules resulted in an unknown pattern.
15-
#[cfg_attr(feature = "std", error("pattern {0:b} not recognized"))]
13+
#[error("pattern {0:b} not recognized")]
1614
Pattern(u16),
1715
/// A bar's width or spacing is not valid.
18-
#[cfg_attr(feature = "std", error("bar is not valid"))]
16+
#[error("bar is not valid")]
1917
InvalidBar,
2018
/// The stop code at the end is wrong.
21-
#[cfg_attr(feature = "std", error("wrong stop code"))]
19+
#[error("wrong stop code")]
2220
WrongStop,
2321
/// The input was too short.
24-
#[cfg_attr(feature = "std", error("code too short to be valid"))]
22+
#[error("code too short to be valid")]
2523
Short,
2624
/// The code's length can not fit an allowed sequence of modules.
27-
#[cfg_attr(feature = "std", error("length not correct"))]
25+
#[error("length not correct")]
2826
Length,
2927
/// The checksum did not match.
30-
#[cfg_attr(feature = "std", error("checksum mismatch"))]
28+
#[error("checksum mismatch")]
3129
Checksum,
3230
/// The code did not start with a mode signal.
33-
#[cfg_attr(feature = "std", error("start char did not signal mode"))]
31+
#[error("start char did not signal mode")]
3432
NoMode,
3533
/// A symbol occurred in a mode that did not support it or is not implemented.
36-
#[cfg_attr(feature = "std", error("unexpected character {0:x}"))]
34+
#[error("unexpected character {0:x}")]
3735
Unexpected(u8),
3836
/// After decoding the data the conversion from Latin 1 failed.
39-
#[cfg_attr(
40-
feature = "std",
41-
error("characters not covered by Latin 1 were part of this symbol")
42-
)]
37+
#[error("characters not covered by Latin 1 were part of this symbol")]
4338
Latin1,
4439
}
4540

0 commit comments

Comments
 (0)