This commit is contained in:
aottolini 2023-01-09 19:26:42 -03:00
parent 5c8545edc7
commit 9bb57f5687
2 changed files with 9 additions and 14 deletions

View File

@ -1,11 +1,9 @@
// enums1.rs
// No hints this time! ;)
// I AM NOT DONE
#[derive(Debug)]
enum Message {
// TODO: define a few types of messages as used below
Quit, Echo, Move, ChangeColor
}
fn main() {

View File

@ -4,13 +4,11 @@
// Make the code compile and the tests pass!
// Execute `rustlings hint structs3` or use the `hint` watch subcommand for a hint.
// I AM NOT DONE
#[derive(Debug)]
struct Package {
sender_country: String,
recipient_country: String,
weight_in_grams: i32,
pub struct Package {
pub sender_country: String,
pub recipient_country: String,
pub weight_in_grams: i32,
}
impl Package {
@ -26,12 +24,12 @@ impl Package {
}
}
fn is_international(&self) -> ??? {
// Something goes here...
fn is_international(&self) -> bool {
&self.recipient_country != &self.sender_country
}
fn get_fees(&self, cents_per_gram: i32) -> ??? {
// Something goes here...
fn get_fees(&self, cents_per_gram: i32) -> i32 {
&self.weight_in_grams * cents_per_gram
}
}
@ -54,7 +52,6 @@ mod tests {
let recipient_country = String::from("Russia");
let package = Package::new(sender_country, recipient_country, 1200);
assert!(package.is_international());
}