3 ms·
You can (although I wouldn't recommend it) be explicit about the type using 'as': Err("sha1 hash is not valid".into()) as Result<(), Box<dyn Error>> Or I'
by andrewaylett 4y ago
You can (although I wouldn't recommend it) be explicit about the type using 'as':
Err("sha1 hash is not valid".into()) as Result<(), Box<dyn Error>>
Or I'd often reach for an intermediate variable before a turbofish:
let e: Box<dyn Error> = "".into();
Err(e)
The 'as' trick is useful for helping the compiler to understand the return of a lambda where you need it to coerce errors to a specific type.