Skip to content

Commit

Permalink
Remove conditional compilation from mascot constants
Browse files Browse the repository at this point in the history
Using #[cfg(...)] is not ideal here because it harms compile-time
checking. For example, in order to be sure there isn't a type error, one
must separately compile with and without "clippy" when making changes to
the crate.

Rust supports `if` in constants since version 1.46.0.
  • Loading branch information
dtolnay committed Jan 14, 2024
1 parent 9969e83 commit 9fc62d6
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,17 @@ use unicode_width::UnicodeWidthStr;
// Constants! :D
const ENDSL: &[u8] = b"| ";
const ENDSR: &[u8] = b" |\n";
#[cfg(not(feature = "clippy"))]
const MASCOT: &[u8] = br#"
const MASCOT: &[u8] = if !cfg!(feature = "clippy") {
br#"
\
\
_~^~^~_
\) / o o \ (/
'_ - _'
/ '-----' \
"#;

#[cfg(feature = "clippy")]
const MASCOT: &[u8] = br#"
"#
} else {
br#"
\
\
__
Expand All @@ -33,7 +32,8 @@ const MASCOT: &[u8] = br#"
|| ||
|\_/|
\___/
"#;
"#
};
const NEWLINE: u8 = b'\n';
const DASH: u8 = b'-';
const UNDERSCORE: u8 = b'_';
Expand Down

0 comments on commit 9fc62d6

Please sign in to comment.