Rust language (1) How read text file

in #programing4 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.14
TRX 0.30
JST 0.036
BTC 117673.56
ETH 2950.34
SBD 0.86