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`):
|
// Reasons (not to use `spawn_blocking`):
|
||||||
//
|
//
|
||||||
// 1. The work seems not very CPU-bound, it's not heavy computations,
|
// 1. The work seems not very CPU-bound, it's not heavy computations, it's more
|
||||||
// it's more like light computations.
|
// like light computations.
|
||||||
//
|
//
|
||||||
// 2. `spawn_blocking` is not zero-cost — it spawns a new system thread
|
// 2. `spawn_blocking` is not zero-cost — it spawns a new system thread
|
||||||
// + do so other work. This may actually be *worse* then current
|
// + do so other work. This may actually be *worse* then current
|
||||||
// "just do everything in this async fn" approach.
|
// "just do everything in this async fn" approach.
|
||||||
//
|
//
|
||||||
// 3. With `rt-threaded` feature, tokio uses [`num_cpus()`] threads
|
// 3. With `rt-threaded` feature, tokio uses [`num_cpus()`] threads which should
|
||||||
// which should be enough to work fine with one a-bit-blocking task.
|
// be enough to work fine with one a-bit-blocking task. Crucially current
|
||||||
// Crucially current behaviour will be problem mostly with
|
// behaviour will be problem mostly with single-threaded runtimes (and in
|
||||||
// single-threaded runtimes (and in case you're using one, you
|
// case you're using one, you probably don't want to spawn unnecessary
|
||||||
// probably don't want to spawn unnecessary threads anyway).
|
// threads anyway).
|
||||||
//
|
//
|
||||||
// I think if we'll ever change this behaviour, we need to make it
|
// I think if we'll ever change this behaviour, we need to make it
|
||||||
// _configurable_.
|
// _configurable_.
|
||||||
|
|
|
@ -19,10 +19,7 @@ pub(crate) fn fold_attrs<A, R>(
|
||||||
.filter(|&a| filter(a))
|
.filter(|&a| filter(a))
|
||||||
.flat_map(|attribute| {
|
.flat_map(|attribute| {
|
||||||
let Some(key) = attribute.path.get_ident().cloned() else {
|
let Some(key) = attribute.path.get_ident().cloned() else {
|
||||||
return vec![Err(compile_error_at(
|
return vec![Err(compile_error_at("expected an ident", attribute.path.span()))];
|
||||||
"expected an ident",
|
|
||||||
attribute.path.span(),
|
|
||||||
))];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
match (|input: ParseStream<'_>| Attrs::parse_with_key(input, key))
|
match (|input: ParseStream<'_>| Attrs::parse_with_key(input, key))
|
||||||
|
|
|
@ -145,13 +145,12 @@ impl CommandAttr {
|
||||||
}
|
}
|
||||||
|
|
||||||
"command" => {
|
"command" => {
|
||||||
let Some(attr) = key.pop()
|
let Some(attr) = key.pop() else {
|
||||||
else {
|
return Err(compile_error_at(
|
||||||
return Err(compile_error_at(
|
"expected an attribute name",
|
||||||
"expected an attribute name",
|
outermost_key.span(),
|
||||||
outermost_key.span(),
|
));
|
||||||
))
|
};
|
||||||
};
|
|
||||||
|
|
||||||
if let Some(unexpected_key) = key.last() {
|
if let Some(unexpected_key) = key.last() {
|
||||||
return Err(compile_error_at(
|
return Err(compile_error_at(
|
||||||
|
|
|
@ -165,9 +165,9 @@ where
|
||||||
/// the [`Requester`] trait.
|
/// the [`Requester`] trait.
|
||||||
/// 2. `handler` is an `async` function that takes arguments from
|
/// 2. `handler` is an `async` function that takes arguments from
|
||||||
/// [`DependencyMap`] (see below) and returns [`ResponseResult`].
|
/// [`DependencyMap`] (see below) and returns [`ResponseResult`].
|
||||||
/// 3. `cmd` is a type hint for your command enumeration
|
/// 3. `cmd` is a type hint for your command enumeration `MyCommand`: just write
|
||||||
/// `MyCommand`: just write `MyCommand::ty()`. Note that `MyCommand` must
|
/// `MyCommand::ty()`. Note that `MyCommand` must implement the
|
||||||
/// implement the [`BotCommands`] trait, typically via
|
/// [`BotCommands`] trait, typically via
|
||||||
/// `#[derive(BotCommands)]`.
|
/// `#[derive(BotCommands)]`.
|
||||||
///
|
///
|
||||||
/// All the other requirements are about thread safety and data validity and can
|
/// All the other requirements are about thread safety and data validity and can
|
||||||
|
@ -236,8 +236,8 @@ where
|
||||||
/// [`DependencyMap`] (see below) and returns [`ResponseResult`].
|
/// [`DependencyMap`] (see below) and returns [`ResponseResult`].
|
||||||
/// 3. `listener` is something that takes updates from a Telegram server and
|
/// 3. `listener` is something that takes updates from a Telegram server and
|
||||||
/// implements [`UpdateListener`].
|
/// implements [`UpdateListener`].
|
||||||
/// 4. `cmd` is a type hint for your command enumeration `MyCommand`: just
|
/// 4. `cmd` is a type hint for your command enumeration `MyCommand`: just write
|
||||||
/// write `MyCommand::ty()`. Note that `MyCommand` must implement the
|
/// `MyCommand::ty()`. Note that `MyCommand` must implement the
|
||||||
/// [`BotCommands`] trait, typically via `#[derive(BotCommands)]`.
|
/// [`BotCommands`] trait, typically via `#[derive(BotCommands)]`.
|
||||||
///
|
///
|
||||||
/// All the other requirements are about thread safety and data validity and can
|
/// All the other requirements are about thread safety and data validity and can
|
||||||
|
|
Loading…
Reference in a new issue