clippy issues

This commit is contained in:
ssrlive 2024-01-01 14:40:50 +08:00
parent 0edd07479d
commit 61ed6d62c4
3 changed files with 8 additions and 4 deletions

View file

@ -46,6 +46,10 @@ jobs:
profile: minimal profile: minimal
toolchain: stable toolchain: stable
override: true override: true
- name: rustfmt
run: |
rustc --version
cargo fmt --all -- --check
- run: rustup component add clippy - run: rustup component add clippy
- uses: actions-rs/cargo@v1 - uses: actions-rs/cargo@v1
with: with:

View file

@ -88,7 +88,7 @@ pub fn extract_ipaddr_from_dns_message(message: &Message) -> Result<IpAddr, Stri
} }
pub fn extract_domain_from_dns_message(message: &Message) -> Result<String, String> { pub fn extract_domain_from_dns_message(message: &Message) -> Result<String, String> {
let query = message.queries().get(0).ok_or("DnsRequest no query body")?; let query = message.queries().first().ok_or("DnsRequest no query body")?;
let name = query.name().to_string(); let name = query.name().to_string();
Ok(name) Ok(name)
} }

View file

@ -5,7 +5,7 @@ use hashlink::{linked_hash_map::RawEntryMut, LruCache};
use smoltcp::wire::Ipv4Cidr; use smoltcp::wire::Ipv4Cidr;
use std::{ use std::{
collections::HashMap, collections::HashMap,
convert::{TryFrom, TryInto}, convert::TryInto,
net::{IpAddr, Ipv4Addr, Ipv6Addr}, net::{IpAddr, Ipv4Addr, Ipv6Addr},
str::FromStr, str::FromStr,
time::{Duration, Instant}, time::{Duration, Instant},
@ -34,8 +34,8 @@ impl Default for VirtualDns {
Self { Self {
next_addr: start_addr.into(), next_addr: start_addr.into(),
name_to_ip: HashMap::default(), name_to_ip: HashMap::default(),
network_addr: IpAddr::try_from(cidr.network().address().into_address()).unwrap(), network_addr: IpAddr::from(cidr.network().address().into_address()),
broadcast_addr: IpAddr::try_from(cidr.broadcast().unwrap().into_address()).unwrap(), broadcast_addr: IpAddr::from(cidr.broadcast().unwrap().into_address()),
lru_cache: LruCache::new_unbounded(), lru_cache: LruCache::new_unbounded(),
} }
} }