“...I've been working since 2008 with Ruby / Ruby on Rails, love a bit of Elixir / Phoenix and learning Rust. I also poke through other people's code and make PRs for OpenSource Ruby projects that sometimes make it. Currently working for InPay who are based in Denmark...”

Rob Lacey
Senior Software Engineer, UK

I'm a bit Rust(y), thought I'd learn summat new

use std::io::stdin;

struct Visitor {
    name: String,
    greeting: String
}

impl Visitor {
    fn new(name: &str, greeting: &str) -> Self {
        Self {
            name: name.to_lowercase(),
            greeting: greeting.to_string(),
        }
    }

    fn greet_visitor(&self) {
        println!("{}", self.greeting);
    }
}

fn main() {
    println!("Hello, what's your name?");
    let your_name = what_is_your_name();

    if your_name == "bert" {
        println!("Hello, {:?}", your_name);
    } else {
        println!("No, {}, Just no", your_name)
    }

    let visitor_list: [&str; 2] = ["bert", "ernie"];

    for i in 0..=10 {
        println!("{}", i);
    }

    let mut allow = false;

    for v in 0..visitor_list.len() {
        if visitor_list[v] == your_name {
            allow = true;
            println!("Yeah, whatever {}", your_name);
        }
    }

    if allow {
        println!("OK, {}. After much debate. You smell!", your_name)
    }
}

fn what_is_your_name() -> String {
    let mut your_name = String::new();
    stdin().read_line(&mut your_name).expect("FAAIIIILLLED!!!");
    your_name.trim().to_lowercase()
}