edit_string

Function edit_string 

Source
pub fn edit_string(string: &str) -> Result<String, OpenEditorError>
Expand description

Edit a string in the default editor and return the result.

This is a static convenience method equivalent to EditorCallBuilder::new().edit_string(string).

ยงErrors

Returns an error if the editor call fails, or if the temporary file cannot be read or cleaned up.

Examples found in repository?
examples/fill_template.rs (line 7)
3fn main() -> Result<(), Box<dyn std::error::Error>> {
4    let template = "Hello, {name}!\nWelcome to {place}.";
5    // Also works:
6    // let filled_template = EditorCallBuilder::new().edit_string(template)?;
7    let filled_template = edit_string(template)?;
8    println!("Filled Template:\n{filled_template}");
9    Ok(())
10}