Logo

Programming-Idioms

History of Idiom 110 > diff from v89 to v90

Edit summary for version 90 by programming-idioms.org:
[Rust] +DemoURL

Version 89

2022-05-23, 17:23:55

Version 90

2022-05-23, 18:54:25

Idiom #110 Check if string is blank

Set the boolean blank to true if the string s is empty, or null, or contains only whitespace ; false otherwise.

Idiom #110 Check if string is blank

Set the boolean blank to true if the string s is empty, or null, or contains only whitespace ; false otherwise.

Code
str.chars().all(|c| c.is_whitespace())
Code
let blank = s.chars().all(|c| c.is_whitespace());
Doc URL
https://doc.rust-lang.org/std/primitive.char.html#method.is_whitespace
Doc URL
https://doc.rust-lang.org/std/primitive.char.html#method.is_whitespace
Demo URL
https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=204a7d63618678136833d9b114cdb885