pub fn add(left: u64, right: u64) -> u64 {
left + right
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn it_works() {
let result = add(2, 2);
assert_eq!(result, 4);
}
}
use std::borrow::Cow;
pub fn search(query: impl AsRef<str>) -> Result<(), String> {
let q = query.as_ref();
if q.trim().is_empty() {
return Err("query must not be empty".to_string());
}
let encoded: Cow<str> = urlencoding::encode(q);
let url = format!("https://www.google.com/search?q={}", encoded);
webbrowser::open(&url).map_err(|e| format!("failed to open browser: {}", e))
}