Skip to content

Commit

Permalink
cargo project created
Browse files Browse the repository at this point in the history
  • Loading branch information
SudeepMi committed Mar 2, 2024
1 parent c96f400 commit 53e4aeb
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[package]
name = "challenge"
version = "0.1.0"
edition = "2021"

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

[dependencies]
32 changes: 32 additions & 0 deletions src/enum.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Defining a simple enum
enum Weekday {
Monday,
Tuesday,
Wednesday,
Thursday,
Friday,
}

// Enum with associated values
enum Status {
Success(u32),
Error(String),
}

fn main() {
// Using enums in Rust
let today = Weekday::Wednesday;
let result = Status::Success(42);

// Pattern matching on enums
match today {
Weekday::Friday => println!("It's Friday! 🎉"),
_ => println!("It's not Friday yet. Keep coding! 💻"),
}

// Handling different cases of the Status enum
match result {
Status::Success(value) => println!("Operation was successful with value: {}", value),
Status::Error(message) => println!("An error occurred: {}", message),
}
}
File renamed without changes.
3 changes: 3 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn main() {
println!("30 days rust!");
}

0 comments on commit 53e4aeb

Please sign in to comment.