fn save_textfile(&mut self, filename: String) {
        let content: String;
        {
            let guard = self.content.lock().unwrap();
            content = guard.clone();
        }
        info!("Save textfile: {}", filename);
        // Create a path to the desired file
        let path = Path::new(filename.as_str());
        let display = path.display();

        let mut file = match File::create(&path) {
            Err(why) => {
                self.ui
                    .read()
                    .unwrap()
                    .controller_tx
                    .read()
                    .unwrap()
                    .send(ControllerMessage::ShowMessage(format!(
                        "Couldn't open {}: {}",
                        display, why
                    )))
                    .unwrap();
                return;
            }
            Ok(file) => file,
        };

        // Read the file contents into a string, returns `io::Result<usize>`
        if let Err(why) = file.write_all(content.as_bytes()) {
            self.ui
                .read()
                .unwrap()
                .controller_tx
                .read()
                .unwrap()
                .send(ControllerMessage::ShowMessage(format!(
                    "Couldn't open {}: {}",
                    display, why
                )))
                .unwrap();
        }
        // `file` goes out of scope, and the [filename] file gets closed
    }
/// Saves the current text file to disk
Saves the current text file to disk
Saves the current text file to disk
fn save_textfile(&mut self, filename: String) {
        let content: String;
        {
            let guard = self.content.lock().unwrap();
            content = guard.clone();
        }
        info!("Save textfile: {}", filename);
        // Create a path to the desired file
        let path = Path::new(filename.as_str());
        let display = path.display();
        let mut file = match File::create(&path) {
            Err(why) => {
                self.ui
                    .read()
                    .unwrap()
                    .controller_tx
                    .read()
                    .unwrap()
                    .send(ControllerMessage::ShowMessage(format!(
                        "Couldn't open {}: {}",
                        display, why
                    )))
                    .unwrap();
                return;
            }
            Ok(file) => file,
        };
        // Read the file contents into a string, returns `io::Result<usize>`
        if let Err(why) = file.write_all(content.as_bytes()) {
            self.ui
                .read()
                .unwrap()
                .controller_tx
                .read()
                .unwrap()
                .send(ControllerMessage::ShowMessage(format!(
                    "Couldn't open {}: {}",
                    display, why
                )))
                .unwrap();
        }
        // `file` goes out of scope, and the [filename] file gets closed
    }
fn save_textfile ( & mut self , filename : String ) { let content : String ; { let guard = self . content . lock ( ) . unwrap ( ) ; content = guard . clone ( ) ; } info ! ( " " filename ) ; // Create a path to the desired file let path = Path :: new ( filename . as_str ( ) ) ; let display = path . display ( ) ; let mut file = match File :: create ( & path ) { Err ( why ) => { self . ui . read ( ) . unwrap ( ) . controller_tx . read ( ) . unwrap ( ) . send ( ControllerMessage :: ShowMessage ( format ! ( " " display why ) ) ) . unwrap ( ) ; return ; } Ok ( file ) => file , } ; // Read the file contents into a string, returns `io::Result<usize>` if let Err ( why ) = file . write_all ( content . as_bytes ( ) ) { self . ui . read ( ) . unwrap ( ) . controller_tx . read ( ) . unwrap ( ) . send ( ControllerMessage :: ShowMessage ( format ! ( " " display why ) ) ) . unwrap ( ) ; } // `file` goes out of scope, and the [filename] file gets closed }
Saves the current text file to disk
Saves the current text file to disk
&mut self
filename
String
&mut self
filename
String