-
Notifications
You must be signed in to change notification settings - Fork 0
/
lib.rs
26 lines (22 loc) · 769 Bytes
/
lib.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#[global_allocator]
static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT;
cargo_component_bindings::generate!({
implementor: Greeter,
});
use bindings::exports::hello::city::greeter::Guest;
use bindings::hello::city::city::{send_message, CityInfo};
struct Greeter;
impl Guest for Greeter {
fn run(info: CityInfo) {
if ((info.budget as f64) / (info.head_count as f64)) > 100.0 {
send_message(&format!(
"Welcome to {}, we invite you for a drink!",
info.name
));
} else if info.head_count > 1_000_000 {
send_message(&format!("Welcome to {} mega polis!", info.name));
} else {
send_message(&format!("Welcome to {}!", info.name));
}
}
}