mirror of
https://github.com/rust-lang/rustlings.git
synced 2026-01-11 13:19:18 +00:00
asd
This commit is contained in:
parent
5c8545edc7
commit
9bb57f5687
@ -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() {
|
||||
|
||||
@ -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());
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user