Struct grep_clone::Args
source · pub struct Args {
pub query: String,
pub file_path: String,
pub ignore_case: bool,
}
Expand description
Struct that defines required/supported arguments
The struct can be used to parse arguments from an iterator.
Fields§
§query: String
Pattern used as a substring search.
file_path: String
Path to the file that should be opened and used for searching.
ignore_case: bool
Whether the search should be case-sensitive or not.
Implementations§
source§impl Args
impl Args
sourcepub fn build(args: impl Iterator<Item = String>) -> Result<Args, &'static str>
pub fn build(args: impl Iterator<Item = String>) -> Result<Args, &'static str>
Builds arguments from an iterator
Expects argument in the order: 0. executable_name
- query
- file_path
- ignore_case (optional)
Examples
let iter = vec![
String::from("grep_clone"),
String::from("Who"),
String::from("poem.txt"),
].into_iter();
let args = grep_clone::Args::build(iter);