Open pickfire opened 4 years ago
You can use the short method with no types:
let mut watcher = immediate_watcher(...)?;
The full form (needs a type hint because Watcher
is a trait):
let mut watcher: RecommendedWatcher = Watcher::new_immediate(...)?;
means it's easier to switch implementation:
let mut watcher: INotifyWatcher = Watcher::new_immediate(...)?;
So it might be preferable for demonstration purposes. Otherwise it's just taste.
Ah, I thought let mut watcher = immediate_watcher(...)?;
should be more preferably for a demo to attract attention on the api with shortest code. let mut watcher: INotifyWatcher = Watcher::new_immediate(...)?;
may be useful later in the first page, explaining how to switch implementation.
Since there can only be one
RecommendedWatcher
, why do we still need to explicitly specify the type? Taken from the new docs.Not sure if we can remove the explicit type for
RecommendedWatcher
.