Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: day01 for rust #5

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
367 changes: 367 additions & 0 deletions exercise/rust/day01/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions exercise/rust/day01/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[package]
name = "day01"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
chrono = "0.4.38"
uuid = { version = "1.9.1", features = ["v4", "fast-rng", "macro-diagnostics"] }
once_cell = "1.19.0"
15 changes: 15 additions & 0 deletions exercise/rust/day01/src/food.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
use chrono::{DateTime, Utc};

pub struct Food {
pub expiration_date: DateTime<Utc>,
pub approved_for_consumption: bool,
pub inspector_id: Option<uuid::Uuid>,
}

impl Food {
pub fn is_edible(&self, now: &DateTime<Utc>) -> bool {
self.expiration_date > *now &&
self.approved_for_consumption &&
self.inspector_id.is_some()
}
}
Loading