fn save(&mut self) -> io::Result<usize> {
        if self.filename == "" {
            self.filename = self.prompt("Save as: {} (ESC to cancel)", &mut |_, _, _| {})?;
            if self.filename == "" {
                return Ok(0);
            } else {
                self.syntax = Syntax::from(&self.filename);
            }
        }
        let file_content = self.rows_to_file();
        let len = file_content.len();
        let handle = File::create(&self.filename);
        handle?.write_all(file_content.as_bytes())?;

        // only clear dirty if save worked
        self.dirty = false;
        Ok(len)
    }
/// Save current editor state to a file, prompting for filename if it was not provided.
///
/// # Return Value
/// The number of bytes saved to `self.filename`, if the save was successful.
Save current editor state to a file, prompting for filename if it was not provided.
Save current editor state to a file prompting for filename if it was not provided .
fn save(&mut self) -> io::Result<usize> {
        if self.filename == "" {
            self.filename = self.prompt("Save as: {} (ESC to cancel)", &mut |_, _, _| {})?;
            if self.filename == "" {
                return Ok(0);
            } else {
                self.syntax = Syntax::from(&self.filename);
            }
        }
        let file_content = self.rows_to_file();
        let len = file_content.len();
        let handle = File::create(&self.filename);
        handle?.write_all(file_content.as_bytes())?;
        // only clear dirty if save worked
        self.dirty = false;
        Ok(len)
    }
fn save ( & mut self ) -> io :: Result < usize > { if self . filename == " " { self . filename = self . prompt ( " " , & mut | _ , _ , _ | { } ) ? ; if self . filename == " " { return Ok ( 0 ) ; } else { self . syntax = Syntax :: from ( & self . filename ) ; } } let file_content = self . rows_to_file ( ) ; let len = file_content . len ( ) ; let handle = File :: create ( & self . filename ) ; handle ? . write_all ( file_content . as_bytes ( ) ) ? ; // only clear dirty if save worked self . dirty = false ; Ok ( len ) }
Save current editor state to a file, prompting for filename if it was not provided.
Save current editor state to a file prompting for filename if it was not provided .
&mut self
return value
The number of bytes saved to `self.filename`, if the save was successful.
The number of bytes saved to ` self . filename ` if the save was successful .