[][src]Function minigrep_vbomfim::search

pub fn search<'a>(query: &str, contents: &'a str) -> Vec<&'a str>

Search for a substring (query - first parameter) in the content (contents - second parameter)

Example

let query = "you";
let contents = "How are you doing?\nI'm doing well. Thanks for asking.";
let result = minigrep::search(&query, &contents);
assert_eq!(result,&["How are you doing?"])

Panic

The scenarios in which the function being documented could panic. Callers of the function who don’t want their programs to panic should make sure they don’t call the function in these situations.

Errors:

If the function returns a Result, describing the kinds of errors that might occur and what conditions might cause those errors to be returned can be helpful to callers so they can write code to handle the different kinds of errors in different ways.

Safety

If the function is unsafe to call (we discuss unsafety in Chapter 19), there should be a section explaining why the function is unsafe and covering the invariants that the function expects callers to uphold.