Rust language (1) How read text file

in #programing3 years ago

1_c.png

Trivial task

We read a text file.

Rust 1.55

A bit of documentation:

https://doc.rust-lang.org/std/fs/index.html

https://doc.rust-lang.org/std/fs/fn.read_to_string.html

use std::fs;
fn main() {
    let contents = fs::read_to_string("./cfg.json").expect("some wrong");
    println!("{}",contents);
}

Coin Marketplace

STEEM 0.20
TRX 0.25
JST 0.038
BTC 96907.08
ETH 3380.66
USDT 1.00
SBD 3.23