Skip to content

Instantly share code, notes, and snippets.

@NebulaFox
Last active March 18, 2020 18:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NebulaFox/e6baa2bc937ab0c5f293c09c1fdd95cb to your computer and use it in GitHub Desktop.
Save NebulaFox/e6baa2bc937ab0c5f293c09c1fdd95cb to your computer and use it in GitHub Desktop.
Vec contains problem
fn main() {
let array_str = ["a", "b", "c"];
let array_string = ["a".to_string(), "b".to_string(), "c".to_string()];
let value_str = "b";
let value_string = String::from(value_str);
let result_str = array_str.contains(&value_string);
let result_string = array_string.contains(&value_str);
let result_literal = array_string.contains("b");
println!(
"result: {} {} {}",
result_str, result_string, result_literal
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment