concept term in category rust

appears as: terms, terms, The term, term
Rust in Action

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

If the terms such as stack, heap and reference counting are new to you, don’t put the book down! We’ll spend lots of the book explaining them and how they work together.

This chapter is all about understanding how zeroes and ones can be built up to become much larger objects such as text, images and sound. We will also touch upon how computers do computation. By the end of the chapter, you will have emulated a fully-functional computer with CPU, memory and user-defined functions. You will break apart floating point numbers to create a numeric data type of your own making that only takes up a single byte. The chapter introduces a number of terms that may not be familiar to programmers who have never done systems programming, such as endianness and integer overflow.

To simplify talking about the parts of each opcode, let’s introduce some standard terminology. Each opcode is made up of two bytes, the high byte and the low byte. And each byte is made up of two nibbles, the high nibble and the low nibble respectively. Figure 5.3, “Terms used to refer to parts of CHIP-8 opcodes” provides an illustration.

Figure 5.3. Terms used to refer to parts of CHIP-8 opcodes
ch5 opcode interpretation 4
Listing 8. 19. Implementing std::convert::From for our wrapper error type to simplify its use by downstream programmers (ch8/misc/wraperror2.rs)
use std::io;
use std::fmt;
use std::net;
use std::fs::File;
use std::net::Ipv6Addr;

#[derive(Debug)]
enum UpstreamError{
  IO(io::Error),
  Parsing(net::AddrParseError),
}

impl fmt::Display for UpstreamError {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        write!(f, "{:?}", self) // <1> Implement Display in terms of Debug
    }
}

impl error::Error for UpstreamError { }

impl From<io::Error> for UpstreamError {
    fn from(error: io::Error) -> Self {
        UpstreamError::IO(error)
    }
}

impl From<net::AddrParseError> for UpstreamError {
    fn from(error: net::AddrParseError) -> Self {
        UpstreamError::Parsing(error)
    }
}

fn main() -> Result<(), UpstreamError> {
    let _f = File::open("invisible.txt").map_err(UpstreamError::IO)?;
    let _localhost = "::1".parse::<Ipv6Addr>().map_err(UpstreamError::Parsing)?;

    Ok(())
}