Something went wrong. Try again.
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041//! This module contains the `FileBuffer` struct and associated implementations,//! which is used to represent the file buffer's contents and current file path.//!//! This file is part of sued.//!//! Visit `main.rs` and `lib.rs` for context and usage.//!//! sued is free software licensed under the Apache License, Version 2.0.
/// This struct is used to represent the file buffer./// `contents` will contain the text contents of the file as a Vec,/// and `file_path` will, obviously, contain the file path./// **All instances of this struct should be mutable to work with process_command.**#[derive(Debug, Clone, Default)]pub struct FileBuffer { pub contents: Vec<String>, pub file_path: Option<String>,}
impl FileBuffer { pub fn new() -> FileBuffer { FileBuffer { contents: Vec::new(), file_path: None, } }
pub fn from(contents: Vec<String>) -> Self { FileBuffer { contents, file_path: None, } }}
impl std::fmt::Display for FileBuffer { fn fmt(&self, fmt: &mut std::fmt::Formatter) -> std::fmt::Result { write!(fmt, "{}", self.contents.join("\n")) }}