Advertisement
Guest User

Untitled

a guest
May 19th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. const ALLOWED_OPERATION_CHARS: &'static [char] = &[
  2. '(', ')', '+', '-', '%', '/', '*'
  3. ];
  4.  
  5. fn main() {
  6. let text = String::from("2*(2*2)");
  7. let iter = text.chars().into_iter();
  8. iter.map(|x| {
  9. if ALLOWED_OPERATION_CHARS.iter().any(|y| y.to_owned() == iter.clone().next().unwrap_or(' ')) {
  10. format!("{} ", x)
  11. } else {
  12. x.to_string()
  13. }
  14.  
  15. }).collect::<String>();
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement