Last active
December 17, 2021 23:55
-
-
Save lffg/52d38c2ad49fe68ab341785a19137827 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let source: &str = todo!("get some string slice here"); | |
| // A função `strip_prefix` retorna `Some` contendo o resto da string sem o prefixo se ele existir. | |
| // Se não tiver o prefixo, retorna `None` (análogo ao `false` da outra função). | |
| // Ver: https://doc.rust-lang.org/std/primitive.slice.html#method.strip_prefix | |
| if let Some(tail) = source.strip_prefix(':') { | |
| let cmd: Vec<_> = tail // Agora não preciso mais utilizar um range para remover o prefixo. | |
| .split_ascii_whitespace() | |
| .filter(|s| !s.is_empty()) | |
| .collect(); | |
| // use `cmd` here | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment