Skip to content

Commit

Permalink
chore: warnings+clippy fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
philpax committed Apr 5, 2024
1 parent 3a38937 commit d051de0
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ impl GenerationParameters {
pub fn image_generation(&self) -> Option<store::ImageGeneration> {
match self {
GenerationParameters::Image(image, url) => Some(store::ImageGeneration {
init_image: image.images.get(0)?.clone(),
init_image: image.images.first()?.clone(),
init_url: url.clone(),
resize_mode: image.resize_mode?,
}),
Expand Down
4 changes: 2 additions & 2 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ pub struct Configuration {
runtime: ConfigurationRuntime,
}
impl Configuration {
const FILENAME: &str = "config.toml";
const FILENAME: &'static str = "config.toml";

pub fn init() -> anyhow::Result<()> {
CONFIGURATION
Expand Down Expand Up @@ -249,7 +249,7 @@ struct ConfigurationRuntime {
fn read_tags_from_file(path: &Path) -> anyhow::Result<Tags> {
Ok(std::io::BufReader::new(std::fs::File::open(path)?)
.lines()
.filter_map(|l| l.ok())
.map_while(Result::ok)
.filter(|l| !l.starts_with("//"))
.collect())
}
5 changes: 2 additions & 3 deletions src/custom_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ macro_rules! implement_custom_id_component {
$($member,)*
}
impl $name {
$(const $const: &str = $segment;)*
$(const $const: &'static str = $segment;)*
}
impl TryFrom<&str> for $name {
type Error = anyhow::Error;
Expand Down Expand Up @@ -220,6 +220,5 @@ fn genome_to_hex(genome: TextGenome) -> String {

fn hex_to_genome(hex: &str) -> TextGenome {
bytemuck::cast_slice::<u8, u16>(&hex::decode(hex).unwrap())
.try_into()
.unwrap()
.into()
}
2 changes: 1 addition & 1 deletion src/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use std::collections::HashMap;

pub struct Store(Mutex<rusqlite::Connection>);
impl Store {
const FILENAME: &str = "store.sqlite";
const FILENAME: &'static str = "store.sqlite";

pub fn load() -> anyhow::Result<Self> {
let connection = rusqlite::Connection::open(Self::FILENAME)?;
Expand Down
4 changes: 2 additions & 2 deletions src/wirehead/message_task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ pub async fn task(parameters: Parameters) -> anyhow::Result<()> {
))
.components(|c| {
if to_exilent_enabled {
match images.get(0).and_then(|i| i.1) {
match images.first().and_then(|i| i.1) {
Some(seed) => c.create_action_row(|row| {
row.create_button(|b| {
b.custom_id(
Expand Down Expand Up @@ -114,7 +114,7 @@ pub async fn task(parameters: Parameters) -> anyhow::Result<()> {

channel_id
.send_files(http.as_ref(), images.iter().map(to_attachment_type), |m| {
if let Some(seed) = images.get(0).and_then(|i| i.1) {
if let Some(seed) = images.first().and_then(|i| i.1) {
m.components(|mc| {
mc.create_action_row(|row| {
let g = &genome;
Expand Down
2 changes: 1 addition & 1 deletion src/wirehead/simulation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ impl AsPhenotype for TextGenome {
prefix
.into_iter()
.chain(self.iter().map(|i| tags[*i as usize].as_str()))
.chain(suffix.into_iter())
.chain(suffix)
.collect::<Vec<_>>()
.join(", ")
}
Expand Down

0 comments on commit d051de0

Please sign in to comment.