This commit is contained in:
Maybe Waffle 2023-09-27 12:29:28 +04:00
parent 04df142191
commit 557a7c0df7
4 changed files with 19 additions and 23 deletions

View file

@ -155,18 +155,18 @@ pub(super) async fn worker<B>(
//
// Reasons (not to use `spawn_blocking`):
//
// 1. The work seems not very CPU-bound, it's not heavy computations,
// it's more like light computations.
// 1. The work seems not very CPU-bound, it's not heavy computations, it's more
// like light computations.
//
// 2. `spawn_blocking` is not zero-cost — it spawns a new system thread
// + do so other work. This may actually be *worse* then current
// "just do everything in this async fn" approach.
//
// 3. With `rt-threaded` feature, tokio uses [`num_cpus()`] threads
// which should be enough to work fine with one a-bit-blocking task.
// Crucially current behaviour will be problem mostly with
// single-threaded runtimes (and in case you're using one, you
// probably don't want to spawn unnecessary threads anyway).
// 3. With `rt-threaded` feature, tokio uses [`num_cpus()`] threads which should
// be enough to work fine with one a-bit-blocking task. Crucially current
// behaviour will be problem mostly with single-threaded runtimes (and in
// case you're using one, you probably don't want to spawn unnecessary
// threads anyway).
//
// I think if we'll ever change this behaviour, we need to make it
// _configurable_.

View file

@ -19,10 +19,7 @@ pub(crate) fn fold_attrs<A, R>(
.filter(|&a| filter(a))
.flat_map(|attribute| {
let Some(key) = attribute.path.get_ident().cloned() else {
return vec![Err(compile_error_at(
"expected an ident",
attribute.path.span(),
))];
return vec![Err(compile_error_at("expected an ident", attribute.path.span()))];
};
match (|input: ParseStream<'_>| Attrs::parse_with_key(input, key))

View file

@ -145,12 +145,11 @@ impl CommandAttr {
}
"command" => {
let Some(attr) = key.pop()
else {
let Some(attr) = key.pop() else {
return Err(compile_error_at(
"expected an attribute name",
outermost_key.span(),
))
));
};
if let Some(unexpected_key) = key.last() {

View file

@ -165,9 +165,9 @@ where
/// the [`Requester`] trait.
/// 2. `handler` is an `async` function that takes arguments from
/// [`DependencyMap`] (see below) and returns [`ResponseResult`].
/// 3. `cmd` is a type hint for your command enumeration
/// `MyCommand`: just write `MyCommand::ty()`. Note that `MyCommand` must
/// implement the [`BotCommands`] trait, typically via
/// 3. `cmd` is a type hint for your command enumeration `MyCommand`: just write
/// `MyCommand::ty()`. Note that `MyCommand` must implement the
/// [`BotCommands`] trait, typically via
/// `#[derive(BotCommands)]`.
///
/// All the other requirements are about thread safety and data validity and can
@ -236,8 +236,8 @@ where
/// [`DependencyMap`] (see below) and returns [`ResponseResult`].
/// 3. `listener` is something that takes updates from a Telegram server and
/// implements [`UpdateListener`].
/// 4. `cmd` is a type hint for your command enumeration `MyCommand`: just
/// write `MyCommand::ty()`. Note that `MyCommand` must implement the
/// 4. `cmd` is a type hint for your command enumeration `MyCommand`: just write
/// `MyCommand::ty()`. Note that `MyCommand` must implement the
/// [`BotCommands`] trait, typically via `#[derive(BotCommands)]`.
///
/// All the other requirements are about thread safety and data validity and can