clippy fixes
This commit is contained in:
parent
7cce361c73
commit
2b558aad55
5 changed files with 31 additions and 29 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
|
@ -1570,7 +1570,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "serenity"
|
||||
version = "0.12.5"
|
||||
source = "git+https://github.com/serenity-rs/serenity.git?rev=refs%2Fheads%2Fnext#37b9f433ada8b9ccc5f93f04826403b175855f86"
|
||||
source = "git+https://github.com/serenity-rs/serenity.git?branch=next#37b9f433ada8b9ccc5f93f04826403b175855f86"
|
||||
dependencies = [
|
||||
"aformat",
|
||||
"arrayvec",
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ edition = "2024"
|
|||
|
||||
[dependencies]
|
||||
dotenv = "0.15.0"
|
||||
serenity = { git = "https://github.com/serenity-rs/serenity.git", rev = "refs/heads/next" , features = ["collector"] }
|
||||
serenity = { version = "0.12.5" }
|
||||
tokio = { version = "1.53.1", features = ["rt-multi-thread"] }
|
||||
tracing = "0.1.44"
|
||||
tracing-subscriber = "0.3.23"
|
||||
|
|
@ -15,3 +15,6 @@ thiserror = "2.0.20"
|
|||
nom-language = "0.1.0"
|
||||
rand_xoshiro = "0.8.1"
|
||||
rand = "0.10.2"
|
||||
|
||||
[patch.crates-io]
|
||||
serenity = { git = "https://github.com/serenity-rs/serenity.git", branch = "next" }
|
||||
|
|
|
|||
46
src/dice.rs
46
src/dice.rs
|
|
@ -127,7 +127,7 @@ impl Expression {
|
|||
if i > MAX_DICE_COUNT_PER_ROLL {
|
||||
bail!("Explosion added too many dice.")
|
||||
}
|
||||
if comparers.len() == 0 {
|
||||
if comparers.is_empty() {
|
||||
// Explode on max size dice
|
||||
if rolls[i] == size {
|
||||
rolls.push(rng.random_range(1..=size));
|
||||
|
|
@ -185,25 +185,25 @@ impl Expression {
|
|||
let mut skip = false;
|
||||
let roll = rolls[idx];
|
||||
let rank = ranks[idx];
|
||||
if let Some(kh) = kh {
|
||||
if rolls.len() - 1 - rank >= kh {
|
||||
skip = true;
|
||||
}
|
||||
if let Some(kh) = kh
|
||||
&& rolls.len() - 1 - rank >= kh
|
||||
{
|
||||
skip = true;
|
||||
}
|
||||
if let Some(dh) = dh {
|
||||
if rolls.len() - 1 - rank < dh {
|
||||
skip = true;
|
||||
}
|
||||
if let Some(dh) = dh
|
||||
&& rolls.len() - 1 - rank < dh
|
||||
{
|
||||
skip = true;
|
||||
}
|
||||
if let Some(kl) = kl {
|
||||
if rank >= kl {
|
||||
skip = true;
|
||||
}
|
||||
if let Some(kl) = kl
|
||||
&& rank >= kl
|
||||
{
|
||||
skip = true;
|
||||
}
|
||||
if let Some(dl) = dl {
|
||||
if rank < dl {
|
||||
skip = true;
|
||||
}
|
||||
if let Some(dl) = dl
|
||||
&& rank < dl
|
||||
{
|
||||
skip = true;
|
||||
}
|
||||
if !skip {
|
||||
result_set.push(roll as f64);
|
||||
|
|
@ -298,19 +298,19 @@ impl Expression {
|
|||
bail!("Invalid die size.")
|
||||
}
|
||||
|
||||
if let Some(_) = x {
|
||||
if x.is_some() {
|
||||
bail!("Not implemented yet");
|
||||
}
|
||||
if let Some(_) = kh {
|
||||
if kh.is_some() {
|
||||
bail!("Not implemented yet");
|
||||
};
|
||||
if let Some(_) = kl {
|
||||
if kl.is_some() {
|
||||
bail!("Not implemented yet");
|
||||
};
|
||||
if let Some(_) = dh {
|
||||
if dh.is_some() {
|
||||
bail!("Not implemented yet");
|
||||
};
|
||||
if let Some(_) = dl {
|
||||
if dl.is_some() {
|
||||
bail!("Not implemented yet");
|
||||
};
|
||||
|
||||
|
|
@ -477,7 +477,7 @@ impl DiscordMdWitness {
|
|||
parent.buffers[self.buffer_idx] = self
|
||||
.result
|
||||
.map(|result| format!("**{result} = …**"))
|
||||
.unwrap_or_else(|| String::new());
|
||||
.unwrap_or_default();
|
||||
} else if let Some(result) = self.result {
|
||||
parent.buffers[self.buffer_idx].insert_str(0, &format!("**{result}** = "));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -172,7 +172,7 @@ pub async fn roll(ctx: &Context, command: &CommandInteraction) -> anyhow::Result
|
|||
.map(|s| s.parse::<u64>().context("Seed could not be parsed. Make sure it is a 64 bit integer between 0 and 2^64-1."))
|
||||
.transpose()?;
|
||||
|
||||
let expression = parsing::parse(&formula).context("Dice formula could not be parsed.")?;
|
||||
let expression = parsing::parse(formula).context("Dice formula could not be parsed.")?;
|
||||
|
||||
let seed = fixed_seed.unwrap_or_else(|| rand::rng().next_u64());
|
||||
let mut rng = rand_xoshiro::Xoshiro256PlusPlus::seed_from_u64(seed);
|
||||
|
|
@ -255,8 +255,7 @@ pub async fn roll(ctx: &Context, command: &CommandInteraction) -> anyhow::Result
|
|||
Ok(())
|
||||
}
|
||||
|
||||
if let Ok(_) = inner(ctx, command).await {
|
||||
} else if let Err(err) = inner(ctx, command).await {
|
||||
if let Err(err) = inner(ctx, command).await {
|
||||
warn!("Error encountered: {err:?}");
|
||||
command
|
||||
.create_response(
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ fn expr<'c, 'i>(
|
|||
)
|
||||
.map(|(count, size, (kh, kl, dh, dl, x))| {
|
||||
Dice(DiceFormula {
|
||||
count: count.map(|n| Box::new(n)),
|
||||
count: count.map(Box::new),
|
||||
size: Box::new(size),
|
||||
kh: kh.map(|n| Box::new(n.unwrap_or(Const(1f64)))),
|
||||
kl: kl.map(|n| Box::new(n.unwrap_or(Const(1f64)))),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue