fn parse(rep: &str) -> Result<Self, MonikerError> {
        if rep.chars().nth(0) != Some('.') {
            return Err(MonikerError::invalid_moniker(rep));
        }
        let stripped_input = rep.strip_prefix(".").unwrap();

        let mut up_vs_down = stripped_input.splitn(2, '/');
        let set_one = up_vs_down.next().unwrap();
        let set_two = up_vs_down.next();

        let up_string = set_one.strip_prefix("\\").unwrap_or(set_one);
        let down_string = set_two.unwrap_or("");

        if up_string == "" && down_string == "" {
            return Ok(Self::new(vec![], vec![]));
        }

        if down_string.contains("\\") {
            return Err(MonikerError::invalid_moniker(rep));
        }

        let up_path;
        if up_string == "" {
            up_path = vec![];
        } else {
            up_path = up_string
                .split("\\")
                .map(ChildMoniker::parse)
                .collect::<Result<Vec<ChildMoniker>, MonikerError>>()?;
        }

        let down_path;
        if down_string == "" {
            down_path = vec![];
        } else {
            down_path = down_string
                .split("/")
                .map(ChildMoniker::parse)
                .collect::<Result<Vec<ChildMoniker>, MonikerError>>()?;
        }
        Ok(RelativeMoniker { up_path, down_path })
    }
/// Parses n `RelativeMoniker` from a string.
///
/// Input strings should be of the format
/// `.(\<name>(:<collection>)?:<instance_id>)*(/<name>(:<collection>)?:<instance_id>)*`, such
/// as `.\foo:42/bar:12/baz:54` or `./biz:foo:42`.
Parses n `RelativeMoniker` from a string.
Parses n ` RelativeMoniker ` from a string .
fn parse(rep: &str) -> Result<Self, MonikerError> {
        if rep.chars().nth(0) != Some('.') {
            return Err(MonikerError::invalid_moniker(rep));
        }
        let stripped_input = rep.strip_prefix(".").unwrap();
        let mut up_vs_down = stripped_input.splitn(2, '/');
        let set_one = up_vs_down.next().unwrap();
        let set_two = up_vs_down.next();
        let up_string = set_one.strip_prefix("\\").unwrap_or(set_one);
        let down_string = set_two.unwrap_or("");
        if up_string == "" && down_string == "" {
            return Ok(Self::new(vec![], vec![]));
        }
        if down_string.contains("\\") {
            return Err(MonikerError::invalid_moniker(rep));
        }
        let up_path;
        if up_string == "" {
            up_path = vec![];
        } else {
            up_path = up_string
                .split("\\")
                .map(ChildMoniker::parse)
                .collect::<Result<Vec<ChildMoniker>, MonikerError>>()?;
        }
        let down_path;
        if down_string == "" {
            down_path = vec![];
        } else {
            down_path = down_string
                .split("/")
                .map(ChildMoniker::parse)
                .collect::<Result<Vec<ChildMoniker>, MonikerError>>()?;
        }
        Ok(RelativeMoniker { up_path, down_path })
    }
fn parse ( rep : & str ) -> Result < Self , MonikerError > { if rep . chars ( ) . nth ( 0 ) != Some ( '.' ) { return Err ( MonikerError :: invalid_moniker ( rep ) ) ; } let stripped_input = rep . strip_prefix ( " " ) . unwrap ( ) ; let mut up_vs_down = stripped_input . splitn ( 2 , '/' ) ; let set_one = up_vs_down . next ( ) . unwrap ( ) ; let set_two = up_vs_down . next ( ) ; let up_string = set_one . strip_prefix ( " \\ " ) . unwrap_or ( set_one ) ; let down_string = set_two . unwrap_or ( " " ) ; if up_string == " " && down_string == " " { return Ok ( Self :: new ( vec ! [ ] , vec ! [ ] ) ) ; } if down_string . contains ( " \\ " ) { return Err ( MonikerError :: invalid_moniker ( rep ) ) ; } let up_path ; if up_string == " " { up_path = vec ! [ ] ; } else { up_path = up_string . split ( " \\ " ) . map ( ChildMoniker :: parse ) . collect :: < Result < Vec < ChildMoniker > , MonikerError > > ( ) ? ; } let down_path ; if down_string == " " { down_path = vec ! [ ] ; } else { down_path = down_string . split ( " " ) . map ( ChildMoniker :: parse ) . collect :: < Result < Vec < ChildMoniker > , MonikerError > > ( ) ? ; } Ok ( RelativeMoniker { up_path , down_path } ) }
Parses n `RelativeMoniker` from a string.
Parses n ` RelativeMoniker ` from a string .
rep
&str
rep
&str