scope<S, R> static method
Creates a ShardTester around shard, runs body, and disposes the
tester in a finally block. Returns whatever body returns.
Type parameter S is the shard's state type (named S to avoid
shadowing the outer class's T in this static method).
Implementation
static Future<R> scope<S, R>(
Shard<S> shard,
Future<R> Function(ShardTester<S> tester) body,
) async {
final tester = ShardTester<S>(shard);
try {
return await body(tester);
} finally {
await tester.dispose();
}
}