projects
/
rust-101.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
try and fail to make the mobile style prettier
[rust-101.git]
/
workspace
/
src
/
part11.rs
diff --git
a/workspace/src/part11.rs
b/workspace/src/part11.rs
index ac19371db6d69594d87526d5e46d7267f4631de9..a93ad07ed684bb301ac3d14b501f68cfe7713b97 100644
(file)
--- a/
workspace/src/part11.rs
+++ b/
workspace/src/part11.rs
@@
-23,7
+23,7
@@
impl Callbacks {
// Registration simply stores the callback.
pub fn register(&mut self, callback: Box<FnMut(i32)>) {
// Registration simply stores the callback.
pub fn register(&mut self, callback: Box<FnMut(i32)>) {
- unimplemented!()
+ self.callbacks.push(callback);
}
// We can also write a generic version of `register`, such that it will be instantiated with some concrete closure type `F`
}
// We can also write a generic version of `register`, such that it will be instantiated with some concrete closure type `F`
@@
-59,7
+59,7
@@
pub fn main() {
}
}
-// **Exercise 11.1**: We made the arbitrary choice of using `i32` for the arguments. Generalize the data
-
structures above
+// **Exercise 11.1**: We made the arbitrary choice of using `i32` for the arguments. Generalize the data
structures above
// to work with an arbitrary type `T` that's passed to the callbacks. Since you need to call multiple callbacks with the
// to work with an arbitrary type `T` that's passed to the callbacks. Since you need to call multiple callbacks with the
-// same `t: T`, you will either have to restrict `T` to `Copy` types, or pass a
borrow
.
+// same `t: T`, you will either have to restrict `T` to `Copy` types, or pass a
reference
.