use<R> method
Executes the given block function on this resource and then closes it down correctly whether an exception is thrown or not.
Implementation
Future<R> use<R>(Future<R> Function(Resource resource) block) async {
try {
return block(this);
} on Exception {
rethrow;
} finally {
await close();
}
}