Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
bircni committed Jan 12, 2025
1 parent c86f116 commit 90d31e4
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 21 deletions.
8 changes: 1 addition & 7 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
lfs: true
- name: Install Rust stable
uses: dtolnay/rust-toolchain@master
with:
Expand All @@ -30,8 +28,6 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
lfs: true
- name: Install Rust stable
uses: dtolnay/rust-toolchain@master
with:
Expand All @@ -46,12 +42,10 @@ jobs:
strategy:
matrix:
os: ["ubuntu", "windows", "macos"]
version: ["stable", "beta", "1.84"]
version: ["stable", "beta", "1.80"]
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
lfs: true
- name: Install Rust ${{ matrix.version }}
uses: dtolnay/rust-toolchain@master
with:
Expand Down
5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ insta = "1"
rspec = "1"

[lints.rust]
unsafe_code = "forbid"
unsafe_code = "warn"
deprecated = "warn"

[lints.clippy]
Expand All @@ -40,6 +40,9 @@ suspicious = "warn"

# Could be enabled in the future
too_many_lines = { level = "allow", priority = 10 }
unwrap_used = { level = "allow", priority = 10 }
expect_used = { level = "allow", priority = 10 }
wildcard_imports = { level = "allow", priority = 10 }

# not necessary
module_name_repetitions = { level = "allow", priority = 10 }
4 changes: 1 addition & 3 deletions src/color.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ pub enum Color {

fn truecolor_support() -> bool {
let truecolor = env::var("COLORTERM");
truecolor.map_or(false, |truecolor| {
truecolor == "truecolor" || truecolor == "24bit"
})
truecolor.is_ok_and(|truecolor| truecolor == "truecolor" || truecolor == "24bit")
}

#[allow(missing_docs)]
Expand Down
3 changes: 3 additions & 0 deletions src/control.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ use std::sync::LazyLock;
/// control::set_virtual_terminal(true).unwrap();
/// println!("{}", "bright cyan".bright_cyan()); // will print correctly
/// ```
/// # Errors
/// This function will return `Ok(())` if the operation was successful.
#[allow(clippy::result_unit_err)]
#[cfg(windows)]
pub fn set_virtual_terminal(use_virtual: bool) -> Result<(), ()> {
Expand All @@ -34,6 +36,7 @@ pub fn set_virtual_terminal(use_virtual: bool) -> Result<(), ()> {
STD_OUTPUT_HANDLE,
};

#[allow(unsafe_code)] // needed here
unsafe {
let handle = GetStdHandle(STD_OUTPUT_HANDLE);
let mut original_mode = 0;
Expand Down
3 changes: 2 additions & 1 deletion src/customcolors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ pub struct CustomColor {
/// This only makes custom color creation easier.
impl CustomColor {
/// Create a new custom color
#[must_use] pub const fn new(r: u8, g: u8, b: u8) -> Self {
#[must_use]
pub const fn new(r: u8, g: u8, b: u8) -> Self {
Self { r, g, b }
}
}
Expand Down
27 changes: 18 additions & 9 deletions src/style.rs
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,8 @@ impl Style {
/// assert_eq!(colored.style.contains(Styles::Italic), true);
/// assert_eq!(colored.style.contains(Styles::Dimmed), false);
/// ```
#[must_use] pub const fn contains(self, style: Styles) -> bool {
#[must_use]
pub const fn contains(self, style: Styles) -> bool {
let s = style.to_u8();
self.0 & s == s
}
Expand Down Expand Up @@ -389,49 +390,57 @@ impl Style {
}

/// Makes this `Style` include Bold.
#[must_use] pub fn bold(mut self) -> Self {
#[must_use]
pub fn bold(mut self) -> Self {
self.add(Styles::Bold);
self
}

/// Makes this `Style` include Dimmed.
#[must_use] pub fn dimmed(mut self) -> Self {
#[must_use]
pub fn dimmed(mut self) -> Self {
self.add(Styles::Dimmed);
self
}

/// Makes this `Style` include Underline.
#[must_use] pub fn underline(mut self) -> Self {
#[must_use]
pub fn underline(mut self) -> Self {
self.add(Styles::Underline);
self
}

/// Makes this `Style` include Reversed.
#[must_use] pub fn reversed(mut self) -> Self {
#[must_use]
pub fn reversed(mut self) -> Self {
self.add(Styles::Reversed);
self
}

/// Makes this `Style` include Italic.
#[must_use] pub fn italic(mut self) -> Self {
#[must_use]
pub fn italic(mut self) -> Self {
self.add(Styles::Italic);
self
}

/// Makes this `Style` include Blink.
#[must_use] pub fn blink(mut self) -> Self {
#[must_use]
pub fn blink(mut self) -> Self {
self.add(Styles::Blink);
self
}

/// Makes this `Style` include Hidden.
#[must_use] pub fn hidden(mut self) -> Self {
#[must_use]
pub fn hidden(mut self) -> Self {
self.add(Styles::Hidden);
self
}

/// Makes this `Style` include Strikethrough.
#[must_use] pub fn strikethrough(mut self) -> Self {
#[must_use]
pub fn strikethrough(mut self) -> Self {
self.add(Styles::Strikethrough);
self
}
Expand Down

0 comments on commit 90d31e4

Please sign in to comment.