Compare commits

..

2 Commits

Author SHA1 Message Date
668a91941b Merge pull request 'style: Format code with fmt' (#48) from fmt into main
### Détails

`fmt` permet de formater le code Rust, je pense que c'est une bonne chose que l'on utilise l'utilitaire aevc la commande `cargo fmt` nous pourrons mettre en place un test de validation des DAs quand nous aurons une CI avec la commande suivante `cargo fmt --all -- --check`.

### Pourquoi ?

Pour rendre le code plus lisible

### Documentation

https://rust-lang.github.io/rustfmt/

Reviewed-on: #48
Reviewed-by: theo <theo.lettermann@gmail.com>
2024-08-08 15:08:03 +02:00
Simon C
0eaf238735 style: Format code with fmt 2024-08-08 15:01:28 +02:00
8 changed files with 28 additions and 18 deletions

View File

@ -9,7 +9,9 @@ async fn main() {
let router = get_router(assets_path.as_path()); let router = get_router(assets_path.as_path());
// TODO: select port based on available port (or ask in CLI) // TODO: select port based on available port (or ask in CLI)
let listener = tokio::net::TcpListener::bind("localhost:3000").await.unwrap(); let listener = tokio::net::TcpListener::bind("localhost:3000")
.await
.unwrap();
println!("Listening on: http://{}", listener.local_addr().unwrap()); println!("Listening on: http://{}", listener.local_addr().unwrap());
axum::serve(listener, router).await.unwrap(); axum::serve(listener, router).await.unwrap();
} }

View File

@ -11,10 +11,10 @@ struct HelloResponse {
async fn hello() -> impl IntoResponse { async fn hello() -> impl IntoResponse {
HelloResponse { HelloResponse {
name: "Theo".to_string(), name: "Theo".to_string(),
}.into_response() }
.into_response()
} }
pub fn get_routes() -> Router { pub fn get_routes() -> Router {
Router::new() Router::new().route("/", routing::get(hello))
.route("/", routing::get(hello))
} }

View File

@ -25,7 +25,9 @@ impl MenuResponse {
fn get_classes(&self, is_current_item: &bool) -> String { fn get_classes(&self, is_current_item: &bool) -> String {
let common_classes = match self.mobile { let common_classes = match self.mobile {
true => "block border-l-4 py-2 pl-3 pr-4 text-base font-medium".to_string(), true => "block border-l-4 py-2 pl-3 pr-4 text-base font-medium".to_string(),
false => "inline-flex items-center border-b-2 px-1 pt-1 text-sm font-medium".to_string(), false => {
"inline-flex items-center border-b-2 px-1 pt-1 text-sm font-medium".to_string()
}
}; };
match (self.mobile, is_current_item) { match (self.mobile, is_current_item) {
(true, true) => common_classes + " border-indigo-500 bg-indigo-50 text-indigo-700", (true, true) => common_classes + " border-indigo-500 bg-indigo-50 text-indigo-700",
@ -51,10 +53,10 @@ async fn menu(Query(params): Query<MenuParameters>) -> impl IntoResponse {
current: false, current: false,
}, },
], ],
}.into_response() }
.into_response()
} }
pub fn get_routes() -> Router { pub fn get_routes() -> Router {
Router::new() Router::new().route("/menu", routing::get(menu))
.route("/menu", routing::get(menu))
} }

View File

@ -56,10 +56,10 @@ async fn menu(Query(params): Query<MenuParameters>) -> impl IntoResponse {
current: false, current: false,
}, },
], ],
}.into_response() }
.into_response()
} }
pub fn get_routes() -> Router { pub fn get_routes() -> Router {
Router::new() Router::new().route("/menu", routing::get(menu))
.route("/menu", routing::get(menu))
} }

View File

@ -16,7 +16,10 @@ fn main() {
// Add local lib directory to the linker search path (for def files and static libs) // Add local lib directory to the linker search path (for def files and static libs)
let static_lib_path = manifest_path.join("lib"); let static_lib_path = manifest_path.join("lib");
println!("cargo::rustc-link-search=native={}", static_lib_path.display()); println!(
"cargo::rustc-link-search=native={}",
static_lib_path.display()
);
// Add the SESAM_FSV_LIB_PATH to the linker search path // Add the SESAM_FSV_LIB_PATH to the linker search path
let fsv_lib_path = PathBuf::from(env::var("SESAM_FSV_LIB_PATH").unwrap()); let fsv_lib_path = PathBuf::from(env::var("SESAM_FSV_LIB_PATH").unwrap());
@ -31,6 +34,9 @@ fn main() {
} }
// Link the SESAM_FSV_SSVLIB dynamic library // Link the SESAM_FSV_SSVLIB dynamic library
println!("cargo::rustc-link-lib=dylib={}", env::var("SESAM_FSV_SSVLIB").unwrap()); println!(
"cargo::rustc-link-lib=dylib={}",
env::var("SESAM_FSV_SSVLIB").unwrap()
);
// TODO : try `raw-dylib` instead of `dylib` on Windows to avoid the need of the `lib` headers compiled from the `def` // TODO : try `raw-dylib` instead of `dylib` on Windows to avoid the need of the `lib` headers compiled from the `def`
} }