wake: simplify separator check as suggested
This commit is contained in:
parent
abe8f30637
commit
c71ef11df2
|
@ -10,12 +10,7 @@ struct CmdArgs {
|
||||||
fn main() {
|
fn main() {
|
||||||
let args = CmdArgs::parse();
|
let args = CmdArgs::parse();
|
||||||
if let Some(m) = args.mac {
|
if let Some(m) = args.mac {
|
||||||
let mut sep: char = '/';
|
let sep = m.chars().find(|ch| *ch == ':' || *ch == '-').unwrap_or('/');
|
||||||
[":", "-"].iter().for_each(|s| {
|
|
||||||
if m.contains(s) {
|
|
||||||
sep = s.chars().next().unwrap();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
let wol = wakey::WolPacket::from_string(&m, sep);
|
let wol = wakey::WolPacket::from_string(&m, sep);
|
||||||
if wol.send_magic().is_ok() {
|
if wol.send_magic().is_ok() {
|
||||||
println!("sent the magic packet.");
|
println!("sent the magic packet.");
|
||||||
|
|
Loading…
Reference in New Issue
Block a user