From 557a7c0df7832337d7cc61188dd17b625b4953bf Mon Sep 17 00:00:00 2001 From: Maybe Waffle Date: Wed, 27 Sep 2023 12:29:28 +0400 Subject: [PATCH] re-fmt --- .../teloxide-core/src/adaptors/throttle/worker.rs | 14 +++++++------- crates/teloxide-macros/src/attr.rs | 5 +---- crates/teloxide-macros/src/command_attr.rs | 13 ++++++------- crates/teloxide/src/repls/commands_repl.rs | 10 +++++----- 4 files changed, 19 insertions(+), 23 deletions(-) diff --git a/crates/teloxide-core/src/adaptors/throttle/worker.rs b/crates/teloxide-core/src/adaptors/throttle/worker.rs index 7aa42692..67e7ecf3 100644 --- a/crates/teloxide-core/src/adaptors/throttle/worker.rs +++ b/crates/teloxide-core/src/adaptors/throttle/worker.rs @@ -155,18 +155,18 @@ pub(super) async fn worker( // // 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_. diff --git a/crates/teloxide-macros/src/attr.rs b/crates/teloxide-macros/src/attr.rs index bc3e7dd3..c581b91c 100644 --- a/crates/teloxide-macros/src/attr.rs +++ b/crates/teloxide-macros/src/attr.rs @@ -19,10 +19,7 @@ pub(crate) fn fold_attrs( .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)) diff --git a/crates/teloxide-macros/src/command_attr.rs b/crates/teloxide-macros/src/command_attr.rs index 9d1e9550..91f87bc9 100644 --- a/crates/teloxide-macros/src/command_attr.rs +++ b/crates/teloxide-macros/src/command_attr.rs @@ -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( diff --git a/crates/teloxide/src/repls/commands_repl.rs b/crates/teloxide/src/repls/commands_repl.rs index 68093d8f..c846089e 100644 --- a/crates/teloxide/src/repls/commands_repl.rs +++ b/crates/teloxide/src/repls/commands_repl.rs @@ -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