From de9aae1e8208a155f6cf2950bf93fc8056088719 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Niederb=C3=BChl?= Date: Fri, 5 Jun 2020 15:55:47 +0200 Subject: [PATCH] Use string slices as function arguments Also use the same names as parameters. --- examples/word-count/src/lib.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/word-count/src/lib.rs b/examples/word-count/src/lib.rs index d79e6b50..e9bdd423 100644 --- a/examples/word-count/src/lib.rs +++ b/examples/word-count/src/lib.rs @@ -7,11 +7,11 @@ use rayon::prelude::*; /// Searches for the word, parallelized by rayon #[pyfunction] -fn search(py: Python<'_>, contents: &str, search: String) -> PyResult { +fn search(py: Python<'_>, contents: &str, needle: &str) -> PyResult { let count = py.allow_threads(move || { contents .par_lines() - .map(|line| count_line(line, &search)) + .map(|line| count_line(line, needle)) .sum() }); Ok(count) @@ -19,8 +19,8 @@ fn search(py: Python<'_>, contents: &str, search: String) -> PyResult { /// Searches for a word in a classic sequential fashion #[pyfunction] -fn search_sequential(contents: &str, needle: String) -> PyResult { - let result = contents.lines().map(|line| count_line(line, &needle)).sum(); +fn search_sequential(contents: &str, needle: &str) -> PyResult { + let result = contents.lines().map(|line| count_line(line, needle)).sum(); Ok(result) }