Returns true if the given size matches the comparison.
(&self, size: u16)
| 842 | impl QuerySizePseudo { |
| 843 | /// Returns true if the given size matches the comparison. |
| 844 | pub fn matches(&self, size: u16) -> bool { |
| 845 | let target = { |
| 846 | let c: Cursor = self.comparison.value.into(); |
| 847 | c.token().value() as u16 |
| 848 | }; |
| 849 | match &self.comparison.operator { |
| 850 | None => size == target, |
| 851 | Some(SizeOperator::NotEqual(_)) => size != target, |
| 852 | Some(SizeOperator::GreaterThan(_)) => size > target, |
| 853 | Some(SizeOperator::LessThan(_)) => size < target, |
| 854 | Some(SizeOperator::GreaterThanOrEqual(_)) => size >= target, |
| 855 | Some(SizeOperator::LessThanOrEqual(_)) => size <= target, |
| 856 | } |
| 857 | } |
| 858 | } |
| 859 | |
| 860 | #[cfg(test)] |