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
//! Command-line interface
mod agent;
mod critic;
mod env;
mod optimizer;
mod options;
mod seq_mod;
mod simulator;
mod updater;

pub use options::Options;

/// Can be updated from a value of type T.
pub trait Update<T> {
    /// Update in-place from the given source value.
    fn update(&mut self, source: T);
}

/// Can be updated from a value of type T.
pub trait WithUpdate<T> {
    /// Apply an update from the given source value.
    fn with_update(self, source: T) -> Self;
}

impl<T, U: Update<T>> WithUpdate<T> for U {
    fn with_update(mut self, source: T) -> Self {
        self.update(source);
        self
    }
}