by curious145454 · 4y ago · 0 comments
I fail to see how hiding self.send() inside of IntoFuture makes anything simpler.
StorageRequest::new().set_debug(true).send().await?;
vs
StorageRequest::new().set_debug(true).await?;
Just reading the later variant makes me wonder "What are we (a)waiting for here? For set_debug to succeed?". I'd definitely stick to the former variant.
Perhaps, it's just not the best example and there are better usages than the one chosen to illustrate it.
foo::some_func(foo::SomeFuncArgs{
a: 8,
b: Some(false),
..Default::default()
})
Personally I would be really happy if `..` could default to `..Default::default()` which would make this a lot cleaner. But even then needing to name a type for the argument struct is noisy. Language-integrated keyword arguments would make this a lot cleaner: foo::some_func(
a=8,
b=Some(false)) foo::some_func({
.a = 8,
.b = false
});
(I view this and std::span as the only two usable features in C++20, and pretty much everything else can go to the dustbin or the drawing board.) let mut foo = build_foo()
.with_a(8);
if need_to_set_b {
foo = foo.with_b(false);
}
let foo = foo.build();And yes, the example is not the best.
With tooling this would make your resulting type be a StorageResponse. The whole point is that you can have that "request type" be awaitable.
It's simpler for library users, because they don't need to know which particular method finalizes a builder to obtain a future from it, and `.await` just works in more situations.
Say, `for await x in connection.item {}` not real syntax but something similar might be in Rust's future.