code: def handle_ends(index1, s, index2, t):
      
      edge_end = False
      if s == 1.0:
          s = 0.0
          index1 = (index1 + 1) % 3
          edge_end = True
      # NOTE: This is not a typo, the values can be updated twice if both ``s``
      #       and ``t`` are ``1.0``
      if t == 1.0:
          t = 0.0
          index2 = (index2 + 1) % 3
          edge_end = True
      is_corner = s == 0.0 or t == 0.0
      return edge_end, is_corner, (index1, s, index2, t)
docs: Updates intersection parameters if it is on the end of an edge.
  
      .. note::
  
         This is a helper used only by :meth:`.Surface.intersect`.
  
      Does nothing if the intersection happens in the middle of two
      edges.
  
      If the intersection occurs at the end of the first curve,
      moves it to the beginning of the next edge. Similar for the
      second curve.
  
      This function is used as a pre-processing step before passing
      an intersection to :func:`classify_intersection`. There, only
      corners that **begin** an edge are considered, since that
      function is trying to determine which edge to **move forward** on.
  
      Args:
          index1 (int): The index (among 0, 1, 2) of the first edge in the
              intersection.
          s (float): The parameter along the first curve of the intersection.
          index2 (int): The index (among 0, 1, 2) of the second edge in the
              intersection.
          t (float): The parameter along the second curve of the intersection.
  
      Returns:
          Tuple[bool, bool, Tuple[int, float, int, float]]: A triple of:
  
          * flag indicating if the intersection is at the end of an edge
          * flag indicating if the intersection is a "corner"
          * 4-tuple of the "updated" values ``(index1, s, index2, t)``