Skip to content

Commit

Permalink
feat(#9): match
Browse files Browse the repository at this point in the history
  • Loading branch information
h1alexbel committed Jun 5, 2024
1 parent 7062ad5 commit 3ae99e2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use crate::xml::storage::touch_storage;

#[tokio::main]
async fn main() {
touch_storage();
touch_storage().unwrap();
let app = Router::new().route("/", get(home::home));
let listener = tokio::net::TcpListener::bind("0.0.0.0:3000").await.unwrap();
axum::serve(listener, app).await.unwrap();
Expand Down
12 changes: 6 additions & 6 deletions src/xml/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,19 @@ use std::fs::File;

use log::info;

pub fn touch_storage() {
pub fn touch_storage() -> Result<File, Error> {
let path = "fakehub.xml";
info!("Initializing XML storage: {path}");
let creating = File::create(path);
let _ = match creating {
match creating {
Ok(file) => {
info!("'{path}' initialized");
Ok::<File, Error>(file)
Ok(file)
}
Err(err) => {
panic!("fakehub storage failed to initialize in '{path}': {err}");
panic!("fakehub storage failed to initialize in '{path}': {err}")
}
};
}
}

#[cfg(test)]
Expand All @@ -52,7 +52,7 @@ mod tests {

#[test]
fn creates_xml_storage() {
touch_storage();
touch_storage().unwrap();
let storage = "fakehub.xml";
let exists = Path::new(storage).exists();
assert!(
Expand Down

0 comments on commit 3ae99e2

Please sign in to comment.