// FIXME: this is super-hacky and because of separators, since they need to know
//        if there is a value surrounding them; ideally this would return an array of
//        struct, which would hold common attributes and a reference to yaml, each value
//        would be then validated
this is super-hacky and because of separators, since they need to know
if there is a value surrounding them; ideally this would return an array of
struct, which would hold common attributes and a reference to yaml, each value
would be then validated
this is super - hacky and because of separators since they need to know if there is a value surrounding them ; ideally this would return an array of struct which would hold common attributes and a reference to yaml each value would be then validated
pub fn populate_values(&mut self) -> String {
        let values_yaml = &self.c["values"];
        if values_yaml.is_badvalue() || values_yaml.is_null() {
            panic!("No values to display.");
        }
        let values = values_yaml.as_vec().unwrap();
        let mut out: String = String::new();
        // was there a previous value already displayed?
        let mut prev_was_set = false;
        // are we suppose to display a separator?
        let mut separator_pending: Option<String> = None;
        // FIXME: all of this logic should live outside of this module
        for v in values {
            let simple_value = SimpleValue::new(v);
            let value_type = simple_value.value_type.as_str();
            if value_type == "separator" {
                let separator = Separator::new(v, &simple_value);
                let separator_display = separator.display();
                if separator.is_display_always() {
                    out += &separator_display.unwrap();
                } else {
                    separator_pending = separator_display;
                }
            } else if let Some(s) = self.display_master.display_value(v, &simple_value) {
                // add separator if it is needed
                if let Some(separator) = separator_pending.clone() {
                    if prev_was_set {
                        // println!("add separator {:?}", simple_value);
                        out += &separator;
                        separator_pending = None;
                    }
                }
                out += &s;
                prev_was_set = true;
            }
        }
        out.clone()
    }
pub fn populate_values ( & mut self ) -> String { let values_yaml = & self . c [ " " ] ; if values_yaml . is_badvalue ( ) || values_yaml . is_null ( ) { panic ! ( " " ) ; } let values = values_yaml . as_vec ( ) . unwrap ( ) ; let mut out : String = String :: new ( ) ; // was there a previous value already displayed? let mut prev_was_set = false ; // are we suppose to display a separator? let mut separator_pending : Option < String > = None ; // FIXME: all of this logic should live outside of this module for v in values { let simple_value = SimpleValue :: new ( v ) ; let value_type = simple_value . value_type . as_str ( ) ; if value_type == " " { let separator = Separator :: new ( v , & simple_value ) ; let separator_display = separator . display ( ) ; if separator . is_display_always ( ) { out += & separator_display . unwrap ( ) ; } else { separator_pending = separator_display ; } } else if let Some ( s ) = self . display_master . display_value ( v , & simple_value ) { // add separator if it is needed if let Some ( separator ) = separator_pending . clone ( ) { if prev_was_set { // println!("add separator {:?}", simple_value); out += & separator ; separator_pending = None ; } } out += & s ; prev_was_set = true ; } } out . clone ( ) }
FIXME: this is super-hacky and because of separators, since they need to know
if there is a value surrounding them; ideally this would return an array of
struct, which would hold common attributes and a reference to yaml, each value
would be then validated
FIXME : this is super - hacky and because of separators since they need to know if there is a value surrounding them ; ideally this would return an array of struct which would hold common attributes and a reference to yaml each value would be then validated
&mut self