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
sort
Whether or not to sort chunks before comparinglowercase
Whether or not to convert chunks to lowercase before comparingseparators
List of separators to use for splitting lines into chunksl1
The first linel2
The second line
Examples found in repository?
More examples
examples/construction.rs (line 10)
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
fn main() -> Result<()> {
println!("Example with two lines");
let config = Config::from_lines(false, false, vec![' '], "Hello World", "hello World");
println!("{:?}", config);
compare_lines(config)?;
println!("Example with using a single file containing two lines");
let config = Config::from_file(
false,
false,
vec![' '],
PathBuf::from("examples/twolines.txt"),
);
println!("{:?}", config);
compare_lines(config)
}
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
sort
Whether or not to sort chunks before comparinglowercase
Whether or not to convert chunks to lowercase before comparingseparators
List of separators to use for splitting lines into chunksfilepath
Path to the file that contains the two lines
Examples found in repository?
More examples
examples/construction.rs (lines 15-20)
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
fn main() -> Result<()> {
println!("Example with two lines");
let config = Config::from_lines(false, false, vec![' '], "Hello World", "hello World");
println!("{:?}", config);
compare_lines(config)?;
println!("Example with using a single file containing two lines");
let config = Config::from_file(
false,
false,
vec![' '],
PathBuf::from("examples/twolines.txt"),
);
println!("{:?}", config);
compare_lines(config)
}
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) -> Selfwhere
Self: Sized,
I: IntoIterator,
<I as IntoIterator>::Item: Into<OsString> + Clone,
fn from_iter<I>(iter: I) -> Selfwhere Self: Sized, I: IntoIterator, <I as IntoIterator>::Item: Into<OsString> + Clone,
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 moresource§fn from_iter_safe<I>(iter: I) -> Result<Self, Error>where
Self: Sized,
I: IntoIterator,
<I as IntoIterator>::Item: Into<OsString> + Clone,
fn from_iter_safe<I>(iter: I) -> Result<Self, Error>where Self: Sized, I: IntoIterator, <I as IntoIterator>::Item: Into<OsString> + Clone,
Gets the struct from any iterator such as a
Vec
of your making. Read moreAuto Trait Implementations§
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