fn shuttle(
        &self,
        obj: &Self::Id,
        dir: Direction,
    ) -> Result<Self::Id, FlowError> {
        use Direction::*;
        match dir {
            Forward | Backward => {
                let friends = self.friends(obj);
                let nth = if let Some(nth) =
                    friends.iter().position(|id| id == obj)
                {
                    nth
                } else {
                    Err(FlowError::AbandonedChild)?
                };
                let len = friends.len();
                let walk =
                    dir.walk(nth, len).map_err(|_| FlowError::InvalidLen)?;
                Ok(friends[walk].clone())
            }
            Ascend => {
                let candidate = self.parent(obj);
                let res = candidate.map_or(obj.clone(), |id| id);
                Ok(res)
            }
            Descend => {
                let candidate = self.children(obj).get(0).cloned();
                let res = candidate.map_or(obj.clone(), |id| id);
                Ok(res)
            }
        }
    }
/// returns the obj in the corresponding relative position
returns the obj in the corresponding relative position
returns the obj in the corresponding relative position
fn shuttle(
        &self,
        obj: &Self::Id,
        dir: Direction,
    ) -> Result<Self::Id, FlowError> {
        use Direction::*;
        match dir {
            Forward | Backward => {
                let friends = self.friends(obj);
                let nth = if let Some(nth) =
                    friends.iter().position(|id| id == obj)
                {
                    nth
                } else {
                    Err(FlowError::AbandonedChild)?
                };
                let len = friends.len();
                let walk =
                    dir.walk(nth, len).map_err(|_| FlowError::InvalidLen)?;
                Ok(friends[walk].clone())
            }
            Ascend => {
                let candidate = self.parent(obj);
                let res = candidate.map_or(obj.clone(), |id| id);
                Ok(res)
            }
            Descend => {
                let candidate = self.children(obj).get(0).cloned();
                let res = candidate.map_or(obj.clone(), |id| id);
                Ok(res)
            }
        }
    }
fn shuttle ( & self , obj : & Self :: Id , dir : Direction , ) -> Result < Self :: Id , FlowError > { use Direction :: * ; match dir { Forward | Backward => { let friends = self . friends ( obj ) ; let nth = if let Some ( nth ) = friends . iter ( ) . position ( | id | id == obj ) { nth } else { Err ( FlowError :: AbandonedChild ) ? } ; let len = friends . len ( ) ; let walk = dir . walk ( nth , len ) . map_err ( | _ | FlowError :: InvalidLen ) ? ; Ok ( friends [ walk ] . clone ( ) ) } Ascend => { let candidate = self . parent ( obj ) ; let res = candidate . map_or ( obj . clone ( ) , | id | id ) ; Ok ( res ) } Descend => { let candidate = self . children ( obj ) . get ( 0 ) . cloned ( ) ; let res = candidate . map_or ( obj . clone ( ) , | id | id ) ; Ok ( res ) } } }
returns the obj in the corresponding relative position
returns the obj in the corresponding relative position
&self
obj
&Self::Id
dir
Direction
&self
obj
&Self::Id
dir
Direction