elasticsearch_dsl/search/rescoring/
rescore_collection.rs1use super::Rescore;
2use crate::util::ShouldSkip;
3
4#[derive(Default, Clone, PartialEq, Serialize)]
6pub struct RescoreCollection(Vec<Rescore>);
7
8impl std::fmt::Debug for RescoreCollection {
9 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
10 self.0.fmt(f)
11 }
12}
13
14impl IntoIterator for RescoreCollection {
15 type Item = Rescore;
16
17 type IntoIter = std::vec::IntoIter<Self::Item>;
18
19 fn into_iter(self) -> Self::IntoIter {
20 self.0.into_iter()
21 }
22}
23
24impl ShouldSkip for RescoreCollection {
25 fn should_skip(&self) -> bool {
26 self.0.should_skip()
27 }
28}
29
30impl RescoreCollection {
31 pub fn new() -> Self {
33 Default::default()
34 }
35
36 pub fn extend<T>(&mut self, rescore: T)
38 where
39 T: IntoIterator,
40 T::Item: Into<Rescore>,
41 {
42 self.0.extend(
43 rescore
44 .into_iter()
45 .map(Into::into)
46 .filter(ShouldSkip::should_keep),
47 )
48 }
49}