How to properly import structs in Rust?

I wanted to create a struct named "Filme" and include it in the, but I’ve been struggling with that. Here is the file: pub struct Filme{ pub nome: String, pub duracao: u8, pub categorias : String, } impl Filme{ pub fn new(nome:String, duracao:u8, categorias: String) -> Filme{ Filme { nome: nome, duracao: duracao,… Read More How to properly import structs in Rust?

Rust function returning std::time::Instant

I have a function that returns time elapsed. I had originally tried fn insert_test(Table: &mut HashMap<String,String>, items: &Vec<String>) -> std::time::Instant { But the compiler errored on ^^^^^^^^ expected struct `Instant`, found `u128` But the compiler tells me to use u128 instead But how would I know u128 ahead of time? itself does not explicitly… Read More Rust function returning std::time::Instant

Unable to set permissions in RUST

Hi I have just started to program in Rust. Here is my use std::fs::{File, self}; use std::io::Write; use std::os::unix::prelude::PermissionsExt; use std::env; use std::path::{Path, PathBuf}; fn main() { let out_dir = env::var_os("CARGO_MANIFEST_DIR").unwrap(); let dest_path: PathBuf = Path::new(&out_dir).join("target/release/Settings.toml"); println!("{:?}", dest_path.as_os_str()); let f = File::create(dest_path); f.as_ref() .unwrap() .write_all("largest_number = 7".as_bytes()) .unwrap(); set_permissions(f); } fn set_permissions(f: Result<File, std::io::Error>)… Read More Unable to set permissions in RUST