Skip to content

Commit 44570c9

Browse files
authored
remove unneeded unit return type in exercise examples (#1020)
* remove unneeded unit return type in exercise examples * remove unit return from stub
1 parent 65ff71c commit 44570c9

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

exercises/react/example.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ struct ComputeCell<'a, T: Copy> {
4444
cell: Cell<T>,
4545

4646
dependencies: Vec<CellID>,
47-
f: Box<dyn Fn(&[T]) -> T + 'a>,
47+
f: Box<dyn 'a + Fn(&[T]) -> T>,
4848
callbacks_issued: usize,
49-
callbacks: HashMap<CallbackID, Box<dyn FnMut(T) -> () + 'a>>,
49+
callbacks: HashMap<CallbackID, Box<dyn 'a + FnMut(T)>>,
5050
}
5151

5252
impl<T: Copy> Cell<T> {
@@ -60,7 +60,7 @@ impl<T: Copy> Cell<T> {
6060
}
6161

6262
impl<'a, T: Copy> ComputeCell<'a, T> {
63-
fn new<F: Fn(&[T]) -> T + 'a>(initial: T, dependencies: Vec<CellID>, f: F) -> Self {
63+
fn new<F: 'a + Fn(&[T]) -> T>(initial: T, dependencies: Vec<CellID>, f: F) -> Self {
6464
ComputeCell {
6565
cell: Cell::new(initial),
6666

@@ -90,7 +90,7 @@ impl<'a, T: Copy + PartialEq> Reactor<'a, T> {
9090
InputCellID(self.inputs.len() - 1)
9191
}
9292

93-
pub fn create_compute<F: Fn(&[T]) -> T + 'a>(
93+
pub fn create_compute<F: 'a + Fn(&[T]) -> T>(
9494
&mut self,
9595
dependencies: &[CellID],
9696
compute_func: F,
@@ -161,7 +161,7 @@ impl<'a, T: Copy + PartialEq> Reactor<'a, T> {
161161
.is_some()
162162
}
163163

164-
pub fn add_callback<F: FnMut(T) -> () + 'a>(
164+
pub fn add_callback<F: 'a + FnMut(T)>(
165165
&mut self,
166166
id: ComputeCellID,
167167
callback: F,

exercises/react/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ impl<T: Copy + PartialEq> Reactor<T> {
105105
// * Exactly once if the compute cell's value changed as a result of the set_value call.
106106
// The value passed to the callback should be the final value of the compute cell after the
107107
// set_value call.
108-
pub fn add_callback<F: FnMut(T) -> ()>(
108+
pub fn add_callback<F: FnMut(T)>(
109109
&mut self,
110110
_id: ComputeCellID,
111111
_callback: F,

0 commit comments

Comments
 (0)