Skip to content

Commit

Permalink
lib: update getters names
Browse files Browse the repository at this point in the history
According to RFC #0344
(github.com/rust-lang/rfcs/blob/master/text/0344-conventions-galore.md)
a getter and a setter for the attribute `foo` should be named,
respectively, `foo()` and `set_foo()`.
  • Loading branch information
wilkmaia committed Feb 12, 2018
1 parent 42f7dc3 commit f7a3bb1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
10 changes: 5 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,25 @@ impl Config {
Ok(Config { filename, pattern, case_sensitive })
}

pub fn get_filename(&self) -> &str {
pub fn filename(&self) -> &str {
&self.filename
}

pub fn get_pattern(&self) -> &str {
pub fn pattern(&self) -> &str {
&self.pattern
}
}

pub fn run(config: Config) -> Result<(), Box<Error>> {
let mut file = File::open(config.get_filename())?;
let mut file = File::open(config.filename())?;

let mut contents = String::new();
file.read_to_string(&mut contents)?;

let matches = if config.case_sensitive {
search_case_sensitive(config.get_pattern(), &contents)
search_case_sensitive(config.pattern(), &contents)
} else {
search_case_insensitive(config.get_pattern(), &contents)
search_case_insensitive(config.pattern(), &contents)
};

for item in matches {
Expand Down
6 changes: 3 additions & 3 deletions src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const BIN_NAME: &'static str = "bin_name";
const FILENAME: &'static str = "__program_run_test_file__";
const PATTERN: &'static str = "pattern";

fn get_args() -> Vec<String> {
fn args() -> Vec<String> {
let bin_name = BIN_NAME.to_string();
let pattern = PATTERN.to_string();
let filename = FILENAME.to_string();
Expand Down Expand Up @@ -47,7 +47,7 @@ fn delete_file(filename: String) -> Result<process::Output, Box<Error>> {

#[test]
fn create_config() {
let args = get_args();
let args = args();

Config::new(&args).unwrap_or_else(|err| {
panic!(err);
Expand All @@ -66,7 +66,7 @@ fn create_invalid_config() {

#[test]
fn base_program_run() {
let args = get_args();
let args = args();
let config = Config::new(&args).unwrap();

let result = touch_file(FILENAME.to_string()).unwrap();
Expand Down

0 comments on commit f7a3bb1

Please sign in to comment.