pub struct Config { /* private fields */ }Expand description
Configuration struct for comparing two lines
Implementations§
Source§impl Config
impl Config
Sourcepub fn from_cmd_args() -> Config
pub fn from_cmd_args() -> Config
Create a config struct by using command line arguments
Sourcepub fn from_lines(
sort: bool,
lowercase: bool,
separators: Vec<char>,
l1: &str,
l2: &str,
) -> Config
pub fn from_lines( sort: bool, lowercase: bool, separators: Vec<char>, l1: &str, l2: &str, ) -> Config
Create a Config struct that can be used to compare two lines that are given as &str
sortWhether or not to sort chunks before comparinglowercaseWhether or not to convert chunks to lowercase before comparingseparatorsList of separators to use for splitting lines into chunksl1The first linel2The second line
Examples found in repository?
More examples
examples/construction.rs (line 10)
8fn main() -> Result<()> {
9 println!("Example with two lines");
10 let config = Config::from_lines(false, false, vec![' '], "Hello World", "hello World");
11 println!("{:?}", config);
12 compare_lines(config)?;
13
14 println!("Example with using a single file containing two lines");
15 let config = Config::from_file(
16 false,
17 false,
18 vec![' '],
19 PathBuf::from("examples/twolines.txt"),
20 );
21 println!("{:?}", config);
22 compare_lines(config)
23}Sourcepub fn from_file(
sort: bool,
lowercase: bool,
separators: Vec<char>,
filepath: PathBuf,
) -> Config
pub fn from_file( sort: bool, lowercase: bool, separators: Vec<char>, filepath: PathBuf, ) -> Config
Create a Config struct that can be used to compare two lines that are stored in a single file
sortWhether or not to sort chunks before comparinglowercaseWhether or not to convert chunks to lowercase before comparingseparatorsList of separators to use for splitting lines into chunksfilepathPath to the file that contains the two lines
Examples found in repository?
More examples
examples/construction.rs (lines 15-20)
8fn main() -> Result<()> {
9 println!("Example with two lines");
10 let config = Config::from_lines(false, false, vec![' '], "Hello World", "hello World");
11 println!("{:?}", config);
12 compare_lines(config)?;
13
14 println!("Example with using a single file containing two lines");
15 let config = Config::from_file(
16 false,
17 false,
18 vec![' '],
19 PathBuf::from("examples/twolines.txt"),
20 );
21 println!("{:?}", config);
22 compare_lines(config)
23}Trait Implementations§
Source§impl StructOpt for Config
impl StructOpt for Config
Source§fn from_clap(matches: &ArgMatches<'_>) -> Self
fn from_clap(matches: &ArgMatches<'_>) -> Self
Builds the struct from
clap::ArgMatches. It’s guaranteed to succeed
if matches originates from an App generated by StructOpt::clap called on
the same type, otherwise it must panic.Source§fn from_args() -> Selfwhere
Self: Sized,
fn from_args() -> Selfwhere
Self: Sized,
Builds the struct from the command line arguments (
std::env::args_os).
Calls clap::Error::exit on failure, printing the error message and aborting the program.Source§fn from_args_safe() -> Result<Self, Error>where
Self: Sized,
fn from_args_safe() -> Result<Self, Error>where
Self: Sized,
Builds the struct from the command line arguments (
std::env::args_os).
Unlike StructOpt::from_args, returns clap::Error on failure instead of aborting the program,
so calling .exit is up to you.Source§fn from_iter<I>(iter: I) -> Self
fn from_iter<I>(iter: I) -> Self
Gets the struct from any iterator such as a
Vec of your making.
Print the error message and quit the program in case of failure. Read moreAuto Trait Implementations§
impl Freeze for Config
impl RefUnwindSafe for Config
impl Send for Config
impl Sync for Config
impl Unpin for Config
impl UnwindSafe for Config
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more