mirror of
https://github.com/jht5945/rust_util.git
synced 2025-12-27 15:40:03 +08:00
refactor: fix clippy
This commit is contained in:
@@ -26,11 +26,7 @@ impl JoinFilesReader {
|
||||
if !files.is_empty() {
|
||||
file_lines = Some(Box::new(open_file_as_lines(&files[0])?));
|
||||
}
|
||||
Ok(Self {
|
||||
files,
|
||||
file_ptr,
|
||||
file_lines,
|
||||
})
|
||||
Ok(Self { files, file_ptr, file_lines })
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,9 @@ impl MessageType {
|
||||
}
|
||||
|
||||
pub fn get_logger_level() -> MessageType {
|
||||
if let Some(logger_level) = env::var("LOGGER_LEVEL").ok().or(env::var("LOGGER").ok()).or(env::var("LEVEL").ok()) {
|
||||
if let Some(logger_level) = env::var("LOGGER_LEVEL").ok()
|
||||
.or_else(|| env::var("LOGGER").ok())
|
||||
.or_else(|| env::var("LEVEL").ok()) {
|
||||
match logger_level.trim().to_lowercase().as_str() {
|
||||
"debug" | "*" => MessageType::DEBUG,
|
||||
"info" | "?" => MessageType::INFO,
|
||||
|
||||
@@ -12,7 +12,7 @@ pub enum IpAddress {
|
||||
|
||||
impl IpAddress {
|
||||
pub fn parse_ipv4(addr: &str) -> Option<Self> {
|
||||
parse_ipv4_addr(addr).map(|parts| IpAddress::Ipv4(parts))
|
||||
parse_ipv4_addr(addr).map(IpAddress::Ipv4)
|
||||
}
|
||||
|
||||
pub fn to_address(&self) -> String {
|
||||
@@ -23,7 +23,7 @@ impl IpAddress {
|
||||
|
||||
pub fn is_matches(&self, socket_addr: &SocketAddr) -> bool {
|
||||
match self {
|
||||
IpAddress::Ipv4(self_ipv4_octets) => IpAddressMask::Ipv4(self_ipv4_octets.clone(), 32).is_matches(socket_addr),
|
||||
IpAddress::Ipv4(self_ipv4_octets) => IpAddressMask::Ipv4(*self_ipv4_octets, 32).is_matches(socket_addr),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user