Skip to content

Commit 9c7e768

Browse files
feat: Simple enum example
1 parent c6d5b13 commit 9c7e768

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

rustlang_book/enums/src/ip_address.rs

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#[derive(Debug)]
2+
pub enum IpAddress {
3+
V4(u8,u8,u8,u8),
4+
V6(String),
5+
}

rustlang_book/enums/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pub mod ip_address;

rustlang_book/enums/src/main.rs

+5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
use rand::Rng;
22
use std::ops::Range;
3+
use enums::ip_address::{IpAddress};
34

45
fn main() {
6+
let home = IpAddress::V4(127,0,0,1);
7+
8+
println!("{:?}", home);
9+
510
let my_money = Pesa::Thao;
611
let my_money_in_shillings = value_in_shillings(my_money);
712
println!("I have {} shillings", my_money_in_shillings );

0 commit comments

Comments
 (0)