@@ -134,6 +134,16 @@ impl Config {
134
134
/// that uniquely identifies your project, to avoid clashes. For example,
135
135
/// differential dataflow registers a configuration struct under the key
136
136
/// "differential".
137
+ ///
138
+ /// # Examples
139
+ /// ```rust
140
+ /// let mut config = timely::Config::process(3);
141
+ /// config.worker.set("example".to_string(), 7u64);
142
+ /// timely::execute(config, |worker| {
143
+ /// use crate::timely::worker::AsWorker;
144
+ /// assert_eq!(worker.config().get::<u64>("example"), Some(&7));
145
+ /// }).unwrap();
146
+ /// ```
137
147
pub fn set < T > ( & mut self , key : String , val : T ) -> & mut Self
138
148
where
139
149
T : Send + Sync + ' static ,
@@ -147,6 +157,16 @@ impl Config {
147
157
/// Returns `None` if `key` has not previously been set with
148
158
/// [`WorkerConfig::set`], or if the specified `T` does not match the `T`
149
159
/// from the call to `set`.
160
+ ///
161
+ /// # Examples
162
+ /// ```rust
163
+ /// let mut config = timely::Config::process(3);
164
+ /// config.worker.set("example".to_string(), 7u64);
165
+ /// timely::execute(config, |worker| {
166
+ /// use crate::timely::worker::AsWorker;
167
+ /// assert_eq!(worker.config().get::<u64>("example"), Some(&7));
168
+ /// }).unwrap();
169
+ /// ```
150
170
pub fn get < T : ' static > ( & self , key : & str ) -> Option < & T > {
151
171
self . registry . get ( key) . and_then ( |val| val. downcast_ref ( ) )
152
172
}
0 commit comments