diff options
| author | pan93412 <pan93412@gmail.com> | 2023-04-26 17:30:03 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-04-26 11:30:03 +0200 |
| commit | a6df909a8d8018ef87b66b2128c6acfa9fb0599c (patch) | |
| tree | ec1717715dac6944543e13df8b54fef3a3eae038 /src/util | |
| parent | 1d42d6674c5bbeca2be1ca9a35dccd71b9346228 (diff) | |
Allow passing `region` to LocalName (#926)
Diffstat (limited to 'src/util')
| -rw-r--r-- | src/util/mod.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/util/mod.rs b/src/util/mod.rs index 592ba1fa..83ec5961 100644 --- a/src/util/mod.rs +++ b/src/util/mod.rs @@ -226,3 +226,13 @@ pub fn pretty_array_like(parts: &[impl AsRef<str>], trailing_comma: bool) -> Str buf.push(')'); buf } + +/// Check if the [`Option`]-wrapped L is same to R. +/// +/// This is the stable version of [`Option::contains`]. +pub fn option_eq<L, R>(left: Option<L>, other: R) -> bool +where + L: PartialEq<R>, +{ + left.map(|v| v == other).unwrap_or(false) +} |
