Skip to content

Commit b8b7460

Browse files
JomerDevKuabeM
authored andcommitted
Use const asserts where possible
1 parent 9b9076b commit b8b7460

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

src/async_lcd.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,14 @@ where
2727
{
2828
/// Create new instance with only the I2C and delay instance.
2929
pub fn new(i2c: &'a mut I, delay: &'a mut D) -> Self {
30-
assert!(ROWS > 0, "ROWS needs to be larger than zero!");
31-
assert!(COLUMNS > 0, "COLUMNS needs to be larger than zero!");
32-
assert!(
33-
ROWS < 5,
34-
"This library only supports LCDs with up to four rows!"
35-
); // Because we don't have offsets for more than four rows
30+
const {
31+
assert!(ROWS > 0, "ROWS needs to be larger than zero!");
32+
assert!(COLUMNS > 0, "COLUMNS needs to be larger than zero!");
33+
assert!(
34+
ROWS < 5,
35+
"This library only supports LCDs with up to four rows!"
36+
); // Because we don't have offsets for more than four rows
37+
};
3638
Self {
3739
i2c,
3840
delay,

src/sync_lcd.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,14 @@ where
3030
{
3131
/// Create new instance with only the I2C and delay instance.
3232
pub fn new(i2c: &'a mut I, delay: &'a mut D) -> Self {
33-
assert!(ROWS > 0, "ROWS needs to be larger than zero!");
34-
assert!(COLUMNS > 0, "COLUMNS needs to be larger than zero!");
35-
assert!(
36-
ROWS < 5,
37-
"This library only supports LCDs with up to four rows!"
38-
); // Because we don't have offsets for more than four rows
33+
const {
34+
assert!(ROWS > 0, "ROWS needs to be larger than zero!");
35+
assert!(COLUMNS > 0, "COLUMNS needs to be larger than zero!");
36+
assert!(
37+
ROWS < 5,
38+
"This library only supports LCDs with up to four rows!"
39+
); // Because we don't have offsets for more than four rows
40+
};
3941
Self {
4042
i2c,
4143
delay,

0 commit comments

Comments
 (0)