Rust

install

Basic

fn main() {
    println!("Hello, world!");
}

Build & Run

cargo package manager

curl https://sh.rustup.rs -sSf | sh

cargo how to

cargo new hello_world
[package]
name = "hello_world"
version = "0.1.0"
authors = ["Your Name <you@example.com>"]
edition = "2018"

[dependencies]
fn main() {
    println!("Hello, world!");
}
cargo build
./target/debug/hello_world
Hello, world!

Dependency

[dependencies]
time = "0.1.12"
regex = "0.1.41"
ferris-says = "0.2"
use ferris_says::say;
use std::io::{stdout, BufWriter};
use regex::Regex;

fn main() {
    let re = Regex::new(r"^\d{4}-\d{2}-\d{2}__html__quot;).unwrap();
    println!("Did our date match? {}", re.is_match("2014-01-01"));

    let stdout = stdout();
    let message = String::from("Hello fellow Rustaceans!");
    let width = message.chars().count();

    let mut writer = BufWriter::new(stdout.lock());
    say(message.as_bytes(), width, &mut writer).unwrap();
}

ref

rustacean
What Else?
inflearn react api server -50% 할인쿠폰: 15108-f2af1e086101 buy me a coffee