Move Vars into its own module

This commit is contained in:
Benjamin Sago 2017-08-26 20:48:51 +01:00
parent bfb8a5a573
commit bf8ff3675b
2 changed files with 20 additions and 16 deletions

View File

@ -89,6 +89,9 @@ use self::version::VersionString;
mod misfire;
pub use self::misfire::Misfire;
mod vars;
pub use self::vars::Vars;
mod parser;
mod flags;
use self::parser::MatchedFlags;
@ -162,28 +165,13 @@ impl Options {
}
/// Mockable wrapper for `std::env::var_os`.
pub trait Vars {
fn get(&self, name: &'static str) -> Option<OsString>;
}
#[cfg(test)]
pub mod test {
use super::{Options, Misfire, Vars, flags};
use super::{Options, Misfire, flags};
use options::parser::{Arg, MatchedFlags};
use std::ffi::OsString;
// Test impl that just returns the value it has.
impl Vars for Option<OsString> {
fn get(&self, _name: &'static str) -> Option<OsString> {
self.clone()
}
}
#[derive(PartialEq, Debug)]
pub enum Strictnesses {
Last,

16
src/options/vars.rs Normal file
View File

@ -0,0 +1,16 @@
use std::ffi::OsString;
/// Mockable wrapper for `std::env::var_os`.
pub trait Vars {
fn get(&self, name: &'static str) -> Option<OsString>;
}
// Test impl that just returns the value it has.
#[cfg(test)]
impl Vars for Option<OsString> {
fn get(&self, _name: &'static str) -> Option<OsString> {
self.clone()
}
}