Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Default impl for Config #30

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions src/config.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use std::fmt;
use std::iter::{IntoIterator, Iterator};
use std::net::{IpAddr, Ipv4Addr, Ipv6Addr};
use std::slice::Iter;
use {grammar, Network, ParseError, ScopedIp};
use std::net::{IpAddr, Ipv4Addr, Ipv6Addr};

const NAMESERVER_LIMIT:usize = 3;
const SEARCH_LIMIT:usize = 6;
const NAMESERVER_LIMIT: usize = 3;
const SEARCH_LIMIT: usize = 6;

#[derive(Copy, Clone, PartialEq, Eq, Debug)]
enum LastSearch {
Expand All @@ -14,7 +14,6 @@ enum LastSearch {
Search,
}


/// Represent a resolver configuration, as described in `man 5 resolv.conf`.
/// The options and defaults match those in the linux `man` page.
///
Expand Down Expand Up @@ -106,6 +105,12 @@ pub struct Config {
pub family: Vec<Family>,
}

impl Default for Config {
fn default() -> Self {
Self::new()
}
}

impl Config {
/// Create a new `Config` object with default values.
///
Expand Down Expand Up @@ -290,7 +295,7 @@ impl Config {
if let Some(pos) = s.find('.') {
let hn = s[pos + 1..].to_string();
if !hn.is_empty() {
return Some(hn)
return Some(hn);
}
};
None
Expand Down