extendr_api/wrapper/
expr.rs
1use super::*;
2
3#[derive(PartialEq, Clone)]
4pub struct Expressions {
5 pub(crate) robj: Robj,
6}
7
8impl Expressions {
9 pub fn new() -> Self {
11 Expressions::from_values([Robj::from(()); 0])
12 }
13
14 pub fn from_values<V>(values: V) -> Self
24 where
25 V: IntoIterator,
26 V::IntoIter: ExactSizeIterator,
27 V::Item: Into<Robj>,
28 {
29 Self {
30 robj: make_vector(SEXPTYPE::EXPRSXP, values),
31 }
32 }
33
34 pub fn values(&self) -> ListIter {
36 ListIter::from_parts(self.robj.clone(), 0, self.robj.len())
37 }
38}
39
40impl std::default::Default for Expressions {
41 fn default() -> Self {
42 Expressions::new()
43 }
44}
45
46impl std::fmt::Debug for Expressions {
47 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
48 f.debug_struct("Expressions")
49 .field("values", &self.values())
50 .finish()
51 }
52}