From 4b63c7be4207bf2ff7884189a388e83633b20b26 Mon Sep 17 00:00:00 2001 From: Benedikt Peetz Date: Sun, 16 Feb 2025 18:08:47 +0100 Subject: fix(crates/termsize): Remove all of `clippy`'s warnings --- crates/termsize/src/lib.rs | 5 ++--- crates/termsize/src/nix.rs | 11 ++++------- 2 files changed, 6 insertions(+), 10 deletions(-) (limited to 'crates/termsize/src') diff --git a/crates/termsize/src/lib.rs b/crates/termsize/src/lib.rs index e037176..69e7b78 100644 --- a/crates/termsize/src/lib.rs +++ b/crates/termsize/src/lib.rs @@ -1,5 +1,4 @@ #![deny(missing_docs)] - // yt - A fully featured command line YouTube client // // Copyright (C) 2025 softprops @@ -21,7 +20,7 @@ //! ``` /// Container for number of rows and columns -#[derive(Debug)] +#[derive(Debug, Clone, Copy)] pub struct Size { /// number of rows pub rows: u16, @@ -48,6 +47,6 @@ mod tests { use super::get; #[test] fn test_get() { - assert!(get().is_some()) + assert!(get().is_some()); } } diff --git a/crates/termsize/src/nix.rs b/crates/termsize/src/nix.rs index 77fa574..e35aa6b 100644 --- a/crates/termsize/src/nix.rs +++ b/crates/termsize/src/nix.rs @@ -8,19 +8,15 @@ // You should have received a copy of the License along with this program. // If not, see . -extern crate libc; - use std::io::IsTerminal; -use self::{ - super::Size, - libc::{c_ushort, ioctl, STDOUT_FILENO, TIOCGWINSZ}, -}; +use self::super::Size; +use libc::{c_ushort, ioctl, STDOUT_FILENO, TIOCGWINSZ}; /// A representation of the size of the current terminal #[repr(C)] #[derive(Debug)] -pub struct UnixSize { +struct UnixSize { /// number of rows pub rows: c_ushort, /// number of columns @@ -30,6 +26,7 @@ pub struct UnixSize { } /// Gets the current terminal size +#[must_use] pub fn get() -> Option { // http://rosettacode.org/wiki/Terminal_control/Dimensions#Library:_BSD_libc if !std::io::stdout().is_terminal() { -- cgit 1.4.1