Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- trait IsUpperCase {
- fn is_upper_case(&self) -> bool;
- }
- impl IsUpperCase for &str {
- fn is_upper_case(&self) -> bool {
- let word = self.to_string();
- let mut alphabets = word.chars().filter(|c| c.is_alphabetic());
- return match alphabets {
- a if a.count() == 0 => false,
- _ => alphabets.all(|c| c.is_uppercase())
- }
- }
- }
- // I get the following error:
- error[E0008]: cannot bind by-move into a pattern guard
- --> src/lib.rs:20:13
- |
- 20 | a if a.count() == 0 => false,
- | ^ moves value into pattern guard
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement