diff --git a/charybdis-migrate/src/args.rs b/charybdis-migrate/src/args.rs index 6c3fce3..ae40d89 100644 --- a/charybdis-migrate/src/args.rs +++ b/charybdis-migrate/src/args.rs @@ -1,6 +1,5 @@ use clap::Parser; use std::env; -use std::path::PathBuf; #[derive(Parser, Debug)] #[command(author, version, about, long_about = None)] @@ -67,5 +66,7 @@ impl Default for Args { pub(crate) fn get_current_dir() -> String { let path = env::current_dir().expect("Failed to find project root: Could not get current directory"); - PathBuf::from(path).to_str().unwrap().to_string() + path.to_str() + .expect("Failed to find project root: Could not convert path to string") + .to_string() } diff --git a/charybdis-parser/src/schema/code_schema/parser.rs b/charybdis-parser/src/schema/code_schema/parser.rs index 13967ad..184443f 100644 --- a/charybdis-parser/src/schema/code_schema/parser.rs +++ b/charybdis-parser/src/schema/code_schema/parser.rs @@ -101,7 +101,9 @@ fn extract_schema_object(item_struct: &ItemStruct, model_macro: &ModelMacro) -> for field in db_fields { let field_name = field.ident.to_string(); - let field_type = field.column_type_override.unwrap_or_else(|| type_with_arguments(&field.ty_path)); + let field_type = field + .column_type_override + .unwrap_or_else(|| type_with_arguments(&field.ty_path)); let is_static = schema_object.static_columns.contains(&field_name); schema_object.push_field(field_name, field_type, is_static); diff --git a/charybdis/tests/integrations/query.rs b/charybdis/tests/integrations/query.rs index 75f17bf..3966727 100644 --- a/charybdis/tests/integrations/query.rs +++ b/charybdis/tests/integrations/query.rs @@ -28,9 +28,7 @@ async fn model_mutation() { assert_eq!(user, new_user); user.bio = Some("I like beer".to_string()); - if let Some(ref mut address) = user.address { - address.addr_type = AddressTypeCustomField::HomeAddress; - } else {panic!("homer should have address")}; + user.address.as_mut().expect("homer should have address").addr_type = AddressTypeCustomField::HomeAddress; let tag = ("Second Key".to_string(), "Second Value".to_string()); user.user_extra_data.user_tags.push(tag.clone()); @@ -42,9 +40,10 @@ async fn model_mutation() { .expect("Failed to find user"); assert_eq!(user.bio, Some("I like beer".to_string())); - if let Some(ref address) = user.address { - assert_eq!(address.addr_type, AddressTypeCustomField::HomeAddress); - } else {panic!("homer should have address")}; + assert_eq!( + user.address.as_ref().expect("homer should have address").addr_type, + AddressTypeCustomField::HomeAddress + ); assert_eq!(user.user_extra_data.user_tags.last().cloned(), Some(tag)); user.delete().execute(&db_session).await.expect("Failed to delete user");