Search
 
SCRIPT & CODE EXAMPLE
 

RUST

read file contents in rust

use std::fs;

fn main() {
    let data = fs::read_to_string("file_name.txt").expect("Unable to read file");
    println!("{}", data);
}
Comment

read file Rust

use std::fs;

fn main() {
  let content = match fs::read_to_string("Cargo.toml") {
    Result::Ok(value) => value,
    Result::Err(error) => panic!("{}", error) 
  };

  println!("{}", content)
}
Comment

PREVIOUS NEXT
Code Example
Rust :: cargo insall cargo-cahe this version of Cargo is older than the `2021` edition, and only supports `2015` and `2018` editions. 
Rust :: rust random number in range 
Rust :: rust create directory 
Rust :: rust sort vector of number descending 
Rust :: rust implement debug for struct 
Rust :: rust u8 to string 
Rust :: how to concatenate two &str in rust 
Rust :: rust comment 
Rust :: ..= in rust 
Rust :: rust struct default values 
Rust :: calculator in rust 
Rust :: Split text on several separators 
Rust :: rust•armanriazi•borrowchecker•lifetime 
Rust :: rust function 
Rust :: armanriazi•rust•thread•spawin•move•capture 
Rust :: Find the next smaller positive integer containing the same digits 
Rust :: rust•armanriazi•concept•borrowchecker 
Rust :: armanriazi•rust•closures•anonymous•lambda•loosely 
Rust :: rust-analyzer tab space 
Rust :: armanriazi•rust•concept•pattern•newtype 
Rust :: rust tuple vs vec 
Lua :: get all players roblox 
Lua :: luau make kill brick 
Lua :: gfjhhkn roblox 
Lua :: creating new functions using script roblox 
Lua :: lua dict 
Lua :: lua local 
Lua :: lua push to aray 
Lua :: lua table functions 
Lua :: exemple boolean and why it is used 
ADD CONTENT
Topic
Content
Source link
Name
7+8 =