mech_interpreter/stdlib/assign/
record.rs

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
#[macro_use]
use crate::stdlib::*;

// x.a = 1 --------------------------------------------------------------------

// Record Set -----------------------------------------------------------------

#[derive(Debug)]
pub struct RecordSet<T> {
  pub sink: Ref<T>,
  pub source: Ref<T>,
}
impl<T> MechFunction for RecordSet<T> 
  where
  T: Copy + Debug + Clone + Sync + Send + PartialEq + 'static,
  Ref<T>: ToValue
{
  fn solve(&self) {
    let source_ptr = self.source.as_ptr();
    let sink_ptr = self.sink.as_ptr();
    unsafe {
      *sink_ptr = *source_ptr.clone();
    }
  }
  fn out(&self) -> Value { self.sink.to_value() }
  fn to_string(&self) -> String { format!("{:#?}", self) }
}