concept base in category rust

appears as: base, base
Rust in Action

This is an excerpt from Manning's book Rust in Action.

For the curious, our project’s directory structure has changed a great deal. We now have a Cargo.lock file in the base of our project and a target/ directory. Both that file and the directory are managed by cargo. As they are artifacts of the compilation process, we won’t need to touch. Cargo.lock is a file that specifies the exact version numbers of all the dependencies so that future builds are reliably built the same way until Cargo.toml is modified.

2.3.2. Integers with base 2, base 8 and base 16 notation

Rust also has built-in support for numeric literals that allow you to define integers in base 2 (binary), base 8 (octal) and base 16 (hexadecimal). This notation is also available within the formatting macros, such as println!. To demonstrate the three styles, see Listing 2. 4. It produces this output:

Listing 4. 10. Avoiding Ownership Issues with References (ch4/ch4-sat-mailbox.rs)
#[derive(Debug)]
struct CubeSat {
  id: u64,
  mailbox: Mailbox,
}

#[derive(Debug)]
struct Mailbox {
  messages: Vec<Message>,
}

type Message = String;

struct GroundStation;

impl GroundStation {
    fn send(&self, to: &mut CubeSat, msg: Message) {
        to.mailbox.messages.push(msg);
    }
}

impl CubeSat {
    fn recv(&mut self) -> Option<Message> {
        self.mailbox.messages.pop()
    }
}

fn main() {
    let base = GroundStation {};
    let mut sat_a = CubeSat { id: 0, mailbox: Mailbox { messages: vec![] } };

    println!("t0: {:?}", sat_a);
    base.send(&mut sat_a, Message::from("hello there!")); #1

    println!("t1: {:?}", sat_a);

    let msg = sat_a.recv();
    println!("t2: {:?}", sat_a);

    println!("msg: {:?}", msg);
}