1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
use crate::types::Country;
// -----------------------------------------------------------------------------
impl crate::places::place_autocomplete::Request<'_> {
/// Adds the components parameter to the Place API _Place Autocomplete_
/// query.
///
/// ## Arguments
///
/// * `component` ‧ A grouping of places to which you would like to restrict
/// your results. Currently, you can use components to filter by up to 5
/// countries.
///
/// * Multiple components may be stacked together.
#[must_use] pub fn with_component(
mut self,
component: impl Into<Country>
) -> Self {
// Set components in Request struct.
self.components.extend(vec![component.into()]);
// Return modified Request struct to caller.
self
} // fn
/// Adds the components parameter to the Place API _Place Autocomplete_
/// query.
///
/// ## Arguments
///
/// * `components` ‧ A grouping of places to which you would like to restrict
/// your results. Currently, you can use components to filter by up to 5
/// countries.
///
/// * Multiple components may be stacked together.
///
/// # Generics
///
/// This method uses generics to improve ergonomics. The `C` generic is
/// intended to represent any collection that can be iterated over, and the
/// `O` generic is for any type that can be converted to the `Country`
/// type.
#[must_use] pub fn with_components<C, O>(
mut self,
components: C
) -> Self
where
C: IntoIterator<Item = O>,
O: Into<Country> {
// Set components in Request struct.
self.components.extend(components.into_iter().map(Into::<Country>::into));
// Return modified Request struct to caller.
self
} // fn
} // impl