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/doc.rs | |
| parent | 1d42d6674c5bbeca2be1ca9a35dccd71b9346228 (diff) | |
Allow passing `region` to LocalName (#926)
Diffstat (limited to 'src/doc.rs')
| -rw-r--r-- | src/doc.rs | 26 |
1 files changed, 26 insertions, 0 deletions
@@ -591,6 +591,12 @@ impl Region { } } +impl PartialEq<&str> for Region { + fn eq(&self, other: &&str) -> bool { + self.as_str() == *other + } +} + impl FromStr for Region { type Err = &'static str; @@ -688,3 +694,23 @@ cast_to_value! { "y" => Value::Length(v.point.y.into()), }) } + +#[cfg(test)] +mod tests { + use crate::{doc::Region, util::option_eq}; + + #[test] + fn test_partialeq_str() { + let region = Region([b'U', b'S']); + assert_eq!(region, "US"); + assert_ne!(region, "AB"); + } + + #[test] + fn test_region_option_eq() { + let region = Some(Region([b'U', b'S'])); + + assert!(option_eq(region, "US")); + assert!(!option_eq(region, "AB")); + } +} |
