Julio Biason
4 months ago
4 changed files with 29 additions and 0 deletions
@ -0,0 +1,7 @@
|
||||
# This file is automatically @generated by Cargo. |
||||
# It is not intended for manual editing. |
||||
version = 3 |
||||
|
||||
[[package]] |
||||
name = "containstest" |
||||
version = "0.1.0" |
@ -0,0 +1,6 @@
|
||||
[package] |
||||
name = "containstest" |
||||
version = "0.1.0" |
||||
edition = "2021" |
||||
|
||||
[dependencies] |
@ -0,0 +1,3 @@
|
||||
# ContaintsTest |
||||
|
||||
Finding a way to check if any of multiple characters exist in string. |
@ -0,0 +1,13 @@
|
||||
const INVALID: &'static str = " ()[]/\"\\"; |
||||
|
||||
fn invalid(check: &str) -> bool { |
||||
check.chars().any(|char| INVALID.contains(char)) |
||||
} |
||||
|
||||
fn main() { |
||||
let str = "thisisfine"; |
||||
println!("{} - {}", str, invalid(str)); |
||||
|
||||
let str = "this is not fine"; |
||||
println!("{} - {}", str, invalid(str)); |
||||
} |
Loading…
Reference in new issue