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
56
57
58
59
use crate::places::place_autocomplete::request::Request;
use crate::Country;
// -----------------------------------------------------------------------------
impl<'a> Request<'a> {
/// 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.
pub fn with_component(&'a mut self, component: Country) -> &'a mut Self {
// Set components in Request struct.
self.components.extend(vec![component]);
// Return modified Request struct to caller.
self
} // fn
} // impl
// -----------------------------------------------------------------------------
impl<'a> Request<'a> {
/// 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.
pub fn with_components<C, O>(
&'a mut self,
components: C,
) -> &'a mut 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