mirror of
https://github.com/teloxide/teloxide.git
synced 2024-12-22 14:35:36 +01:00
re-fmt
This commit is contained in:
parent
04df142191
commit
557a7c0df7
4 changed files with 19 additions and 23 deletions
|
@ -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_.
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -145,13 +145,12 @@ impl CommandAttr {
|
|||
}
|
||||
|
||||
"command" => {
|
||||
let Some(attr) = key.pop()
|
||||
else {
|
||||
return Err(compile_error_at(
|
||||
"expected an attribute name",
|
||||
outermost_key.span(),
|
||||
))
|
||||
};
|
||||
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() {
|
||||
return Err(compile_error_at(
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue