mirror of
https://github.com/teloxide/teloxide.git
synced 2024-12-22 22:46:39 +01:00
fix typos
This commit is contained in:
parent
52096d269f
commit
fd12e1eb06
4 changed files with 28 additions and 28 deletions
|
@ -18,12 +18,12 @@ pub struct TraceStorage<S> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S> TraceStorage<S> {
|
impl<S> TraceStorage<S> {
|
||||||
#[must_use = "This function is pure, that is does nothing unless it's output is used"]
|
#[must_use = "This function is pure, that is does nothing unless its output is used"]
|
||||||
pub fn new(inner: Arc<S>) -> Arc<Self> {
|
pub fn new(inner: Arc<S>) -> Arc<Self> {
|
||||||
Arc::new(Self { inner })
|
Arc::new(Self { inner })
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use = "This function is pure, that is does nothing unless it's output is used"]
|
#[must_use = "This function is pure, that is does nothing unless its output is used"]
|
||||||
pub fn into_inner(self) -> Arc<S> {
|
pub fn into_inner(self) -> Arc<S> {
|
||||||
self.inner
|
self.inner
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ pub struct AsyncStopFlag(#[pin] Abortable<Pending<()>>);
|
||||||
|
|
||||||
impl AsyncStopToken {
|
impl AsyncStopToken {
|
||||||
/// Create a new token/flag pair.
|
/// Create a new token/flag pair.
|
||||||
#[must_use = "This function is pure, that is does nothing unless it's output is used"]
|
#[must_use = "This function is pure, that is does nothing unless its output is used"]
|
||||||
pub fn new_pair() -> (Self, AsyncStopFlag) {
|
pub fn new_pair() -> (Self, AsyncStopFlag) {
|
||||||
let (handle, reg) = AbortHandle::new_pair();
|
let (handle, reg) = AbortHandle::new_pair();
|
||||||
let token = Self(handle);
|
let token = Self(handle);
|
||||||
|
@ -57,7 +57,7 @@ impl StopToken for AsyncStopToken {
|
||||||
|
|
||||||
impl AsyncStopFlag {
|
impl AsyncStopFlag {
|
||||||
/// Returns true if the stop token linked to `self` was used.
|
/// Returns true if the stop token linked to `self` was used.
|
||||||
#[must_use = "This function is pure, that is does nothing unless it's output is used"]
|
#[must_use = "This function is pure, that is does nothing unless its output is used"]
|
||||||
pub fn is_stopped(&self) -> bool {
|
pub fn is_stopped(&self) -> bool {
|
||||||
self.0.is_aborted()
|
self.0.is_aborted()
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ use teloxide_core::types::User;
|
||||||
/// Passed string will not be automatically escaped because it can contain
|
/// Passed string will not be automatically escaped because it can contain
|
||||||
/// nested markup.
|
/// nested markup.
|
||||||
#[must_use = "This function returns a new string, rather than mutating the argument, so calling it \
|
#[must_use = "This function returns a new string, rather than mutating the argument, so calling it \
|
||||||
without using it's output does nothing useful"]
|
without using its output does nothing useful"]
|
||||||
pub fn bold(s: &str) -> String {
|
pub fn bold(s: &str) -> String {
|
||||||
format!("<b>{}</b>", s)
|
format!("<b>{}</b>", s)
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ pub fn bold(s: &str) -> String {
|
||||||
/// Passed string will not be automatically escaped because it can contain
|
/// Passed string will not be automatically escaped because it can contain
|
||||||
/// nested markup.
|
/// nested markup.
|
||||||
#[must_use = "This function returns a new string, rather than mutating the argument, so calling it \
|
#[must_use = "This function returns a new string, rather than mutating the argument, so calling it \
|
||||||
without using it's output does nothing useful"]
|
without using its output does nothing useful"]
|
||||||
pub fn italic(s: &str) -> String {
|
pub fn italic(s: &str) -> String {
|
||||||
format!("<i>{}</i>", s)
|
format!("<i>{}</i>", s)
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ pub fn italic(s: &str) -> String {
|
||||||
/// Passed string will not be automatically escaped because it can contain
|
/// Passed string will not be automatically escaped because it can contain
|
||||||
/// nested markup.
|
/// nested markup.
|
||||||
#[must_use = "This function returns a new string, rather than mutating the argument, so calling it \
|
#[must_use = "This function returns a new string, rather than mutating the argument, so calling it \
|
||||||
without using it's output does nothing useful"]
|
without using its output does nothing useful"]
|
||||||
pub fn underline(s: &str) -> String {
|
pub fn underline(s: &str) -> String {
|
||||||
format!("<u>{}</u>", s)
|
format!("<u>{}</u>", s)
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@ pub fn underline(s: &str) -> String {
|
||||||
/// Passed string will not be automatically escaped because it can contain
|
/// Passed string will not be automatically escaped because it can contain
|
||||||
/// nested markup.
|
/// nested markup.
|
||||||
#[must_use = "This function returns a new string, rather than mutating the argument, so calling it \
|
#[must_use = "This function returns a new string, rather than mutating the argument, so calling it \
|
||||||
without using it's output does nothing useful"]
|
without using its output does nothing useful"]
|
||||||
pub fn strike(s: &str) -> String {
|
pub fn strike(s: &str) -> String {
|
||||||
format!("<s>{}</s>", s)
|
format!("<s>{}</s>", s)
|
||||||
}
|
}
|
||||||
|
@ -48,14 +48,14 @@ pub fn strike(s: &str) -> String {
|
||||||
///
|
///
|
||||||
/// Escapes the passed URL and the link text.
|
/// Escapes the passed URL and the link text.
|
||||||
#[must_use = "This function returns a new string, rather than mutating the argument, so calling it \
|
#[must_use = "This function returns a new string, rather than mutating the argument, so calling it \
|
||||||
without using it's output does nothing useful"]
|
without using its output does nothing useful"]
|
||||||
pub fn link(url: &str, text: &str) -> String {
|
pub fn link(url: &str, text: &str) -> String {
|
||||||
format!("<a href=\"{}\">{}</a>", escape(url), escape(text))
|
format!("<a href=\"{}\">{}</a>", escape(url), escape(text))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Builds an inline user mention link with an anchor.
|
/// Builds an inline user mention link with an anchor.
|
||||||
#[must_use = "This function returns a new string, rather than mutating the argument, so calling it \
|
#[must_use = "This function returns a new string, rather than mutating the argument, so calling it \
|
||||||
without using it's output does nothing useful"]
|
without using its output does nothing useful"]
|
||||||
pub fn user_mention(user_id: i64, text: &str) -> String {
|
pub fn user_mention(user_id: i64, text: &str) -> String {
|
||||||
link(format!("tg://user?id={}", user_id).as_str(), text)
|
link(format!("tg://user?id={}", user_id).as_str(), text)
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,7 @@ pub fn user_mention(user_id: i64, text: &str) -> String {
|
||||||
///
|
///
|
||||||
/// Escapes HTML characters inside the block.
|
/// Escapes HTML characters inside the block.
|
||||||
#[must_use = "This function returns a new string, rather than mutating the argument, so calling it \
|
#[must_use = "This function returns a new string, rather than mutating the argument, so calling it \
|
||||||
without using it's output does nothing useful"]
|
without using its output does nothing useful"]
|
||||||
pub fn code_block(code: &str) -> String {
|
pub fn code_block(code: &str) -> String {
|
||||||
format!("<pre>{}</pre>", escape(code))
|
format!("<pre>{}</pre>", escape(code))
|
||||||
}
|
}
|
||||||
|
@ -73,7 +73,7 @@ pub fn code_block(code: &str) -> String {
|
||||||
///
|
///
|
||||||
/// Escapes HTML characters inside the block.
|
/// Escapes HTML characters inside the block.
|
||||||
#[must_use = "This function returns a new string, rather than mutating the argument, so calling it \
|
#[must_use = "This function returns a new string, rather than mutating the argument, so calling it \
|
||||||
without using it's output does nothing useful"]
|
without using its output does nothing useful"]
|
||||||
pub fn code_block_with_lang(code: &str, lang: &str) -> String {
|
pub fn code_block_with_lang(code: &str, lang: &str) -> String {
|
||||||
format!(
|
format!(
|
||||||
"<pre><code class=\"language-{}\">{}</code></pre>",
|
"<pre><code class=\"language-{}\">{}</code></pre>",
|
||||||
|
@ -86,7 +86,7 @@ pub fn code_block_with_lang(code: &str, lang: &str) -> String {
|
||||||
///
|
///
|
||||||
/// Escapes HTML characters inside the block.
|
/// Escapes HTML characters inside the block.
|
||||||
#[must_use = "This function returns a new string, rather than mutating the argument, so calling it \
|
#[must_use = "This function returns a new string, rather than mutating the argument, so calling it \
|
||||||
without using it's output does nothing useful"]
|
without using its output does nothing useful"]
|
||||||
pub fn code_inline(s: &str) -> String {
|
pub fn code_inline(s: &str) -> String {
|
||||||
format!("<code>{}</code>", escape(s))
|
format!("<code>{}</code>", escape(s))
|
||||||
}
|
}
|
||||||
|
@ -99,13 +99,13 @@ pub fn code_inline(s: &str) -> String {
|
||||||
///
|
///
|
||||||
/// [spec]: https://core.telegram.org/bots/api#html-style
|
/// [spec]: https://core.telegram.org/bots/api#html-style
|
||||||
#[must_use = "This function returns a new string, rather than mutating the argument, so calling it \
|
#[must_use = "This function returns a new string, rather than mutating the argument, so calling it \
|
||||||
without using it's output does nothing useful"]
|
without using its output does nothing useful"]
|
||||||
pub fn escape(s: &str) -> String {
|
pub fn escape(s: &str) -> String {
|
||||||
s.replace('&', "&").replace('<', "<").replace('>', ">")
|
s.replace('&', "&").replace('<', "<").replace('>', ">")
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use = "This function returns a new string, rather than mutating the argument, so calling it \
|
#[must_use = "This function returns a new string, rather than mutating the argument, so calling it \
|
||||||
without using it's output does nothing useful"]
|
without using its output does nothing useful"]
|
||||||
pub fn user_mention_or_link(user: &User) -> String {
|
pub fn user_mention_or_link(user: &User) -> String {
|
||||||
match user.mention() {
|
match user.mention() {
|
||||||
Some(mention) => mention,
|
Some(mention) => mention,
|
||||||
|
|
|
@ -9,7 +9,7 @@ use teloxide_core::types::User;
|
||||||
/// Passed string will not be automatically escaped because it can contain
|
/// Passed string will not be automatically escaped because it can contain
|
||||||
/// nested markup.
|
/// nested markup.
|
||||||
#[must_use = "This function returns a new string, rather than mutating the argument, so calling it \
|
#[must_use = "This function returns a new string, rather than mutating the argument, so calling it \
|
||||||
without using it's output does nothing useful"]
|
without using its output does nothing useful"]
|
||||||
pub fn bold(s: &str) -> String {
|
pub fn bold(s: &str) -> String {
|
||||||
format!("*{}*", s)
|
format!("*{}*", s)
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ pub fn bold(s: &str) -> String {
|
||||||
/// Passed string will not be automatically escaped because it can contain
|
/// Passed string will not be automatically escaped because it can contain
|
||||||
/// nested markup.
|
/// nested markup.
|
||||||
#[must_use = "This function returns a new string, rather than mutating the argument, so calling it \
|
#[must_use = "This function returns a new string, rather than mutating the argument, so calling it \
|
||||||
without using it's output does nothing useful"]
|
without using its output does nothing useful"]
|
||||||
pub fn italic(s: &str) -> String {
|
pub fn italic(s: &str) -> String {
|
||||||
if s.starts_with("__") && s.ends_with("__") {
|
if s.starts_with("__") && s.ends_with("__") {
|
||||||
format!(r"_{}\r__", &s[..s.len() - 1])
|
format!(r"_{}\r__", &s[..s.len() - 1])
|
||||||
|
@ -35,7 +35,7 @@ pub fn italic(s: &str) -> String {
|
||||||
/// Passed string will not be automatically escaped because it can contain
|
/// Passed string will not be automatically escaped because it can contain
|
||||||
/// nested markup.
|
/// nested markup.
|
||||||
#[must_use = "This function returns a new string, rather than mutating the argument, so calling it \
|
#[must_use = "This function returns a new string, rather than mutating the argument, so calling it \
|
||||||
without using it's output does nothing useful"]
|
without using its output does nothing useful"]
|
||||||
pub fn underline(s: &str) -> String {
|
pub fn underline(s: &str) -> String {
|
||||||
// In case of ambiguity between italic and underline entities
|
// In case of ambiguity between italic and underline entities
|
||||||
// ‘__’ is always greadily treated from left to right as beginning or end of
|
// ‘__’ is always greadily treated from left to right as beginning or end of
|
||||||
|
@ -54,7 +54,7 @@ pub fn underline(s: &str) -> String {
|
||||||
/// Passed string will not be automatically escaped because it can contain
|
/// Passed string will not be automatically escaped because it can contain
|
||||||
/// nested markup.
|
/// nested markup.
|
||||||
#[must_use = "This function returns a new string, rather than mutating the argument, so calling it \
|
#[must_use = "This function returns a new string, rather than mutating the argument, so calling it \
|
||||||
without using it's output does nothing useful"]
|
without using its output does nothing useful"]
|
||||||
pub fn strike(s: &str) -> String {
|
pub fn strike(s: &str) -> String {
|
||||||
format!("~{}~", s)
|
format!("~{}~", s)
|
||||||
}
|
}
|
||||||
|
@ -63,14 +63,14 @@ pub fn strike(s: &str) -> String {
|
||||||
///
|
///
|
||||||
/// Escapes `)` and ``` characters inside the link url.
|
/// Escapes `)` and ``` characters inside the link url.
|
||||||
#[must_use = "This function returns a new string, rather than mutating the argument, so calling it \
|
#[must_use = "This function returns a new string, rather than mutating the argument, so calling it \
|
||||||
without using it's output does nothing useful"]
|
without using its output does nothing useful"]
|
||||||
pub fn link(url: &str, text: &str) -> String {
|
pub fn link(url: &str, text: &str) -> String {
|
||||||
format!("[{}]({})", text, escape_link_url(url))
|
format!("[{}]({})", text, escape_link_url(url))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Builds an inline user mention link with an anchor.
|
/// Builds an inline user mention link with an anchor.
|
||||||
#[must_use = "This function returns a new string, rather than mutating the argument, so calling it \
|
#[must_use = "This function returns a new string, rather than mutating the argument, so calling it \
|
||||||
without using it's output does nothing useful"]
|
without using its output does nothing useful"]
|
||||||
pub fn user_mention(user_id: i64, text: &str) -> String {
|
pub fn user_mention(user_id: i64, text: &str) -> String {
|
||||||
link(format!("tg://user?id={}", user_id).as_str(), text)
|
link(format!("tg://user?id={}", user_id).as_str(), text)
|
||||||
}
|
}
|
||||||
|
@ -79,7 +79,7 @@ pub fn user_mention(user_id: i64, text: &str) -> String {
|
||||||
///
|
///
|
||||||
/// Escapes ``` and `\` characters inside the block.
|
/// Escapes ``` and `\` characters inside the block.
|
||||||
#[must_use = "This function returns a new string, rather than mutating the argument, so calling it \
|
#[must_use = "This function returns a new string, rather than mutating the argument, so calling it \
|
||||||
without using it's output does nothing useful"]
|
without using its output does nothing useful"]
|
||||||
pub fn code_block(code: &str) -> String {
|
pub fn code_block(code: &str) -> String {
|
||||||
format!("```\n{}\n```", escape_code(code))
|
format!("```\n{}\n```", escape_code(code))
|
||||||
}
|
}
|
||||||
|
@ -88,7 +88,7 @@ pub fn code_block(code: &str) -> String {
|
||||||
///
|
///
|
||||||
/// Escapes ``` and `\` characters inside the block.
|
/// Escapes ``` and `\` characters inside the block.
|
||||||
#[must_use = "This function returns a new string, rather than mutating the argument, so calling it \
|
#[must_use = "This function returns a new string, rather than mutating the argument, so calling it \
|
||||||
without using it's output does nothing useful"]
|
without using its output does nothing useful"]
|
||||||
pub fn code_block_with_lang(code: &str, lang: &str) -> String {
|
pub fn code_block_with_lang(code: &str, lang: &str) -> String {
|
||||||
format!("```{}\n{}\n```", escape(lang), escape_code(code))
|
format!("```{}\n{}\n```", escape(lang), escape_code(code))
|
||||||
}
|
}
|
||||||
|
@ -97,7 +97,7 @@ pub fn code_block_with_lang(code: &str, lang: &str) -> String {
|
||||||
///
|
///
|
||||||
/// Escapes ``` and `\` characters inside the block.
|
/// Escapes ``` and `\` characters inside the block.
|
||||||
#[must_use = "This function returns a new string, rather than mutating the argument, so calling it \
|
#[must_use = "This function returns a new string, rather than mutating the argument, so calling it \
|
||||||
without using it's output does nothing useful"]
|
without using its output does nothing useful"]
|
||||||
pub fn code_inline(s: &str) -> String {
|
pub fn code_inline(s: &str) -> String {
|
||||||
format!("`{}`", escape_code(s))
|
format!("`{}`", escape_code(s))
|
||||||
}
|
}
|
||||||
|
@ -107,7 +107,7 @@ pub fn code_inline(s: &str) -> String {
|
||||||
///
|
///
|
||||||
/// [spec]: https://core.telegram.org/bots/api#html-style
|
/// [spec]: https://core.telegram.org/bots/api#html-style
|
||||||
#[must_use = "This function returns a new string, rather than mutating the argument, so calling it \
|
#[must_use = "This function returns a new string, rather than mutating the argument, so calling it \
|
||||||
without using it's output does nothing useful"]
|
without using its output does nothing useful"]
|
||||||
pub fn escape(s: &str) -> String {
|
pub fn escape(s: &str) -> String {
|
||||||
s.replace('_', r"\_")
|
s.replace('_', r"\_")
|
||||||
.replace('*', r"\*")
|
.replace('*', r"\*")
|
||||||
|
@ -132,7 +132,7 @@ pub fn escape(s: &str) -> String {
|
||||||
/// Escapes all markdown special characters specific for the inline link URL
|
/// Escapes all markdown special characters specific for the inline link URL
|
||||||
/// (``` and `)`).
|
/// (``` and `)`).
|
||||||
#[must_use = "This function returns a new string, rather than mutating the argument, so calling it \
|
#[must_use = "This function returns a new string, rather than mutating the argument, so calling it \
|
||||||
without using it's output does nothing useful"]
|
without using its output does nothing useful"]
|
||||||
pub fn escape_link_url(s: &str) -> String {
|
pub fn escape_link_url(s: &str) -> String {
|
||||||
s.replace('`', r"\`").replace(')', r"\)")
|
s.replace('`', r"\`").replace(')', r"\)")
|
||||||
}
|
}
|
||||||
|
@ -140,13 +140,13 @@ pub fn escape_link_url(s: &str) -> String {
|
||||||
/// Escapes all markdown special characters specific for the code block (``` and
|
/// Escapes all markdown special characters specific for the code block (``` and
|
||||||
/// `\`).
|
/// `\`).
|
||||||
#[must_use = "This function returns a new string, rather than mutating the argument, so calling it \
|
#[must_use = "This function returns a new string, rather than mutating the argument, so calling it \
|
||||||
without using it's output does nothing useful"]
|
without using its output does nothing useful"]
|
||||||
pub fn escape_code(s: &str) -> String {
|
pub fn escape_code(s: &str) -> String {
|
||||||
s.replace('\\', r"\\").replace('`', r"\`")
|
s.replace('\\', r"\\").replace('`', r"\`")
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use = "This function returns a new string, rather than mutating the argument, so calling it \
|
#[must_use = "This function returns a new string, rather than mutating the argument, so calling it \
|
||||||
without using it's output does nothing useful"]
|
without using its output does nothing useful"]
|
||||||
pub fn user_mention_or_link(user: &User) -> String {
|
pub fn user_mention_or_link(user: &User) -> String {
|
||||||
match user.mention() {
|
match user.mention() {
|
||||||
Some(mention) => mention,
|
Some(mention) => mention,
|
||||||
|
|
Loading…
Reference in a new issue