crate fn to_location(&self, i: PointIndex) -> Location {
        let point_index = i.index();

        // Find the basic block. We have a vector with the
        // starting index of the statement in each block. Imagine
        // we have statement #22, and we have a vector like:
        //
        // [0, 10, 20]
        //
        // In that case, this represents point_index 2 of
        // basic block BB2. We know this because BB0 accounts for
        // 0..10, BB1 accounts for 11..20, and BB2 accounts for
        // 20...
        //
        // To compute this, we could do a binary search, but
        // because I am lazy we instead iterate through to find
        // the last point where the "first index" (0, 10, or 20)
        // was less than the statement index (22). In our case, this will
        // be (BB2, 20).
        //
        // Nit: we could do a binary search here but I'm too lazy.
        let (block, &first_index) = self
            .statements_before_block
            .iter_enumerated()
            .filter(|(_, first_index)| **first_index <= point_index)
            .last()
            .unwrap();

        Location {
            block,
            statement_index: point_index - first_index,
        }
    }
/// Converts a `PointIndex` back to a location. O(N) where N is
/// the number of blocks; could be faster if we ever cared.
Converts a `PointIndex` back to a location. O(N) where N is
the number of blocks; could be faster if we ever cared.
Converts a ` PointIndex ` back to a location . O ( N ) where N is the number of blocks ; could be faster if we ever cared .
crate fn to_location(&self, i: PointIndex) -> Location {
        let point_index = i.index();
        // Find the basic block. We have a vector with the
        // starting index of the statement in each block. Imagine
        // we have statement #22, and we have a vector like:
        //
        // [0, 10, 20]
        //
        // In that case, this represents point_index 2 of
        // basic block BB2. We know this because BB0 accounts for
        // 0..10, BB1 accounts for 11..20, and BB2 accounts for
        // 20...
        //
        // To compute this, we could do a binary search, but
        // because I am lazy we instead iterate through to find
        // the last point where the "first index" (0, 10, or 20)
        // was less than the statement index (22). In our case, this will
        // be (BB2, 20).
        //
        // Nit: we could do a binary search here but I'm too lazy.
        let (block, &first_index) = self
            .statements_before_block
            .iter_enumerated()
            .filter(|(_, first_index)| **first_index <= point_index)
            .last()
            .unwrap();
        Location {
            block,
            statement_index: point_index - first_index,
        }
    }
crate fn to_location ( & self , i : PointIndex ) -> Location { let point_index = i . index ( ) ; // Find the basic block. We have a vector with the // starting index of the statement in each block. Imagine // we have statement #22, and we have a vector like: // // [0, 10, 20] // // In that case, this represents point_index 2 of // basic block BB2. We know this because BB0 accounts for // 0..10, BB1 accounts for 11..20, and BB2 accounts for // 20... // // To compute this, we could do a binary search, but // because I am lazy we instead iterate through to find // the last point where the "first index" (0, 10, or 20) // was less than the statement index (22). In our case, this will // be (BB2, 20). // // Nit: we could do a binary search here but I'm too lazy. let ( block , & first_index ) = self . statements_before_block . iter_enumerated ( ) . filter ( | ( _ , first_index ) | * * first_index <= point_index ) . last ( ) . unwrap ( ) ; Location { block , statement_index : point_index - first_index , } }
Converts a `PointIndex` back to a location.
Converts a ` PointIndex ` back to a location .
&self
i
PointIndex