|
|
@ -6,7 +6,6 @@ use crate::store::encoded::EncodedQuadsStore; |
|
|
|
use crate::store::numeric_encoder::*; |
|
|
|
use crate::store::numeric_encoder::*; |
|
|
|
use crate::Result; |
|
|
|
use crate::Result; |
|
|
|
use chrono::prelude::*; |
|
|
|
use chrono::prelude::*; |
|
|
|
use language_tags::LanguageTag; |
|
|
|
|
|
|
|
use num_traits::identities::Zero; |
|
|
|
use num_traits::identities::Zero; |
|
|
|
use num_traits::FromPrimitive; |
|
|
|
use num_traits::FromPrimitive; |
|
|
|
use num_traits::One; |
|
|
|
use num_traits::One; |
|
|
@ -19,7 +18,6 @@ use std::collections::BTreeMap; |
|
|
|
use std::collections::HashSet; |
|
|
|
use std::collections::HashSet; |
|
|
|
use std::iter::once; |
|
|
|
use std::iter::once; |
|
|
|
use std::iter::Iterator; |
|
|
|
use std::iter::Iterator; |
|
|
|
use std::str::FromStr; |
|
|
|
|
|
|
|
use std::sync::Arc; |
|
|
|
use std::sync::Arc; |
|
|
|
use std::sync::Mutex; |
|
|
|
use std::sync::Mutex; |
|
|
|
use uuid::Uuid; |
|
|
|
use uuid::Uuid; |
|
|
@ -583,9 +581,15 @@ impl<S: EncodedQuadsStore> SimpleEvaluator<S> { |
|
|
|
if language_range == "*" { |
|
|
|
if language_range == "*" { |
|
|
|
!language_tag.is_empty() |
|
|
|
!language_tag.is_empty() |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
LanguageTag::from_str(&language_range) |
|
|
|
!ZipLongest::new(language_range.split('-'), language_tag.split('-')).any( |
|
|
|
.ok()? |
|
|
|
|parts| match parts { |
|
|
|
.matches(&LanguageTag::from_str(&language_tag).ok()?) |
|
|
|
(Some(range_subtag), Some(language_subtag)) => { |
|
|
|
|
|
|
|
!range_subtag.eq_ignore_ascii_case(language_subtag) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
(Some(_), None) => true, |
|
|
|
|
|
|
|
(None, _) => false, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
) |
|
|
|
} |
|
|
|
} |
|
|
|
.into(), |
|
|
|
.into(), |
|
|
|
) |
|
|
|
) |
|
|
@ -1349,3 +1353,27 @@ impl<'a, S: EncodedQuadsStore> Iterator for DescribeIterator<'a, S> { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct ZipLongest<T1, T2, I1: Iterator<Item = T1>, I2: Iterator<Item = T2>> { |
|
|
|
|
|
|
|
a: I1, |
|
|
|
|
|
|
|
b: I2, |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
impl<T1, T2, I1: Iterator<Item = T1>, I2: Iterator<Item = T2>> ZipLongest<T1, T2, I1, I2> { |
|
|
|
|
|
|
|
fn new(a: I1, b: I2) -> Self { |
|
|
|
|
|
|
|
Self { a, b } |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
impl<T1, T2, I1: Iterator<Item = T1>, I2: Iterator<Item = T2>> Iterator |
|
|
|
|
|
|
|
for ZipLongest<T1, T2, I1, I2> |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
type Item = (Option<T1>, Option<T2>); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fn next(&mut self) -> Option<(Option<T1>, Option<T2>)> { |
|
|
|
|
|
|
|
match (self.a.next(), self.b.next()) { |
|
|
|
|
|
|
|
(None, None) => None, |
|
|
|
|
|
|
|
r => Some(r), |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|