pub fn to_file(&self, outfile: &str) {

        // Serialize Tip to string
        let serialized_tip = match serde_yaml::to_string(&*self) {
            Ok(data) => data,
            Err(error) => {
                panic!("Error serialize tip {}\n{}",
                       &*self, error)
            },
        };

        // Separator string
        let separator = format!("\n\n{}\n", &TIP.separator);

        // Tip data
        let data_file = format!("{}/{}", &CONFIG.data, self.data);
        let tip_contents = match fs::read_to_string(&data_file) {
            Ok(data) => data,
            Err(error) => {
                panic!("Error reading file {}\n{}",
                       &data_file, error)
            },
        };

        // Insert all into a String and finally write to file
        let mut data = String::new();
        data.insert_str(0, tip_contents.as_str());
        data.insert_str(0, separator.as_str());
        data.insert_str(0, serialized_tip.as_str());
        crate::helpers::write_to_file(&outfile, &data);
    }
// Write the Tip structure to file, adding the contents of data
// separated by the separator string.
Write the Tip structure to file, adding the contents of data
separated by the separator string.
Write the Tip structure to file adding the contents of data separated by the separator string .
pub fn to_file(&self, outfile: &str) {
        // Serialize Tip to string
        let serialized_tip = match serde_yaml::to_string(&*self) {
            Ok(data) => data,
            Err(error) => {
                panic!("Error serialize tip {}\n{}",
                       &*self, error)
            },
        };
        // Separator string
        let separator = format!("\n\n{}\n", &TIP.separator);
        // Tip data
        let data_file = format!("{}/{}", &CONFIG.data, self.data);
        let tip_contents = match fs::read_to_string(&data_file) {
            Ok(data) => data,
            Err(error) => {
                panic!("Error reading file {}\n{}",
                       &data_file, error)
            },
        };
        // Insert all into a String and finally write to file
        let mut data = String::new();
        data.insert_str(0, tip_contents.as_str());
        data.insert_str(0, separator.as_str());
        data.insert_str(0, serialized_tip.as_str());
        crate::helpers::write_to_file(&outfile, &data);
    }
pub fn to_file ( & self , outfile : & str ) { // Serialize Tip to string let serialized_tip = match serde_yaml :: to_string ( & * self ) { Ok ( data ) => data , Err ( error ) => { panic ! ( " \n " self error ) } , } ; // Separator string let separator = format ! ( " \n \n \n " TIP separator ) ; // Tip data let data_file = format ! ( " " CONFIG data self data ) ; let tip_contents = match fs :: read_to_string ( & data_file ) { Ok ( data ) => data , Err ( error ) => { panic ! ( " \n " data_file error ) } , } ; // Insert all into a String and finally write to file let mut data = String :: new ( ) ; data . insert_str ( 0 , tip_contents . as_str ( ) ) ; data . insert_str ( 0 , separator . as_str ( ) ) ; data . insert_str ( 0 , serialized_tip . as_str ( ) ) ; crate :: helpers :: write_to_file ( & outfile , & data ) ; }
Write the Tip structure to file, adding the contents of data
separated by the separator string.
Write the Tip structure to file adding the contents of data separated by the separator string .
&self
outfile
&str
&self
outfile
&str