fn horizontal_spacing(&self) -> Vec<f32> {
        let tokens = self.clone().into_iter();
        let mut tkns = tokens.peekable();

        let mut horizontal_spacing = Vec::new();

        while let Some(current_token) = tkns.next() {
            if let Some(next_token) = tkns.peek() {
                let spacing = current_token.x() + current_token.width();
                let last_spacing = *horizontal_spacing.last().unwrap_or(&0.0);

                let mut v = Vec::with_capacity(1);
                v.push(*next_token);

                // Only take into account tokens on the same line
                if (ObjectAlignement::HorizontalAligned == current_token.alignement(v.clone())
                    || ObjectAlignement::HorizontalCenterAligned == current_token.alignement(v))
                    && spacing > 0.0
                    && spacing > last_spacing
                {
                    horizontal_spacing.push(next_token.x() - spacing);
                }
            }
        }

        // removing empty spaces
        horizontal_spacing = horizontal_spacing
            .into_iter()
            .filter(|spacing| *spacing > 0.0)
            .collect::<Vec<f32>>();

        horizontal_spacing.shrink_to_fit();
        horizontal_spacing
    }
/// Collect vertical spacing of a set of tokens
Collect vertical spacing of a set of tokens
Collect vertical spacing of a set of tokens
fn horizontal_spacing(&self) -> Vec<f32> {
        let tokens = self.clone().into_iter();
        let mut tkns = tokens.peekable();
        let mut horizontal_spacing = Vec::new();
        while let Some(current_token) = tkns.next() {
            if let Some(next_token) = tkns.peek() {
                let spacing = current_token.x() + current_token.width();
                let last_spacing = *horizontal_spacing.last().unwrap_or(&0.0);
                let mut v = Vec::with_capacity(1);
                v.push(*next_token);
                // Only take into account tokens on the same line
                if (ObjectAlignement::HorizontalAligned == current_token.alignement(v.clone())
                    || ObjectAlignement::HorizontalCenterAligned == current_token.alignement(v))
                    && spacing > 0.0
                    && spacing > last_spacing
                {
                    horizontal_spacing.push(next_token.x() - spacing);
                }
            }
        }
        // removing empty spaces
        horizontal_spacing = horizontal_spacing
            .into_iter()
            .filter(|spacing| *spacing > 0.0)
            .collect::<Vec<f32>>();
        horizontal_spacing.shrink_to_fit();
        horizontal_spacing
    }
fn horizontal_spacing ( & self ) -> Vec < f32 > { let tokens = self . clone ( ) . into_iter ( ) ; let mut tkns = tokens . peekable ( ) ; let mut horizontal_spacing = Vec :: new ( ) ; while let Some ( current_token ) = tkns . next ( ) { if let Some ( next_token ) = tkns . peek ( ) { let spacing = current_token . x ( ) + current_token . width ( ) ; let last_spacing = * horizontal_spacing . last ( ) . unwrap_or ( & 0.0 ) ; let mut v = Vec :: with_capacity ( 1 ) ; v . push ( * next_token ) ; // Only take into account tokens on the same line if ( ObjectAlignement :: HorizontalAligned == current_token . alignement ( v . clone ( ) ) || ObjectAlignement :: HorizontalCenterAligned == current_token . alignement ( v ) ) && spacing > 0.0 && spacing > last_spacing { horizontal_spacing . push ( next_token . x ( ) - spacing ) ; } } } // removing empty spaces horizontal_spacing = horizontal_spacing . into_iter ( ) . filter ( | spacing | * spacing > 0.0 ) . collect :: < Vec < f32 > > ( ) ; horizontal_spacing . shrink_to_fit ( ) ; horizontal_spacing }
Collect vertical spacing of a set of tokens
Collect vertical spacing of a set of tokens
&self