Skip to content

Commit

Permalink
Fix Clippy warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
surban committed Feb 1, 2024
1 parent 26bc057 commit 3970f78
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 22 deletions.
11 changes: 5 additions & 6 deletions bluer/examples/le_passive_scan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ use bluer::monitor::{Monitor, MonitorEvent, Pattern, RssiSamplingPeriod};
use futures::StreamExt;

fn parse_u8_maybe_hex(s: &str) -> Result<u8, std::num::ParseIntError> {
if s.starts_with("0x") {
u8::from_str_radix(&s[2..], 16)
} else {
s.parse()
match s.strip_prefix("0x") {
Some(hex) => u8::from_str_radix(hex, 16),
None => s.parse(),
}
}

Expand All @@ -29,13 +28,13 @@ async fn main() -> bluer::Result<()> {
None => 0x00,
};
let filter_string: Vec<String> = std::env::args().skip(4).collect();
let content: Vec<u8> = if filter_string.len() > 0 {
let content: Vec<u8> = if !filter_string.is_empty() {
filter_string.iter().map(|s| parse_u8_maybe_hex(s).expect("Failed to parse or-pattern data")).collect()
} else {
vec![0xff, 0xff]
};

if content.len() == 0 {
if content.is_empty() {
panic!("No filter bytes provided");
}

Expand Down
17 changes: 1 addition & 16 deletions bluer/src/adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,7 @@ impl Default for DiscoveryTransport {
/// The default discovery filter does not restrict any devices and provides
/// [duplicate data](Self::duplicate_data).
#[cfg_attr(docsrs, doc(cfg(feature = "bluetoothd")))]
#[derive(Clone, Debug, Eq, PartialEq)]
#[derive(Default, Clone, Debug, Eq, PartialEq)]
pub struct DiscoveryFilter {
/// Filter by service UUIDs, empty means match
/// _any_ UUID.
Expand Down Expand Up @@ -764,21 +764,6 @@ pub struct DiscoveryFilter {
pub _non_exhaustive: (),
}

impl Default for DiscoveryFilter {
fn default() -> Self {
Self {
uuids: Default::default(),
rssi: Default::default(),
pathloss: Default::default(),
transport: Default::default(),
duplicate_data: false,
discoverable: false,
pattern: Default::default(),
_non_exhaustive: (),
}
}
}

impl DiscoveryFilter {
fn into_dict(self) -> HashMap<&'static str, Variant<Box<dyn RefArg>>> {
let mut hm: HashMap<&'static str, Variant<Box<dyn RefArg>>> = HashMap::new();
Expand Down

0 comments on commit 3970f78

Please sign in to comment.