code: func (l Line) IntersectRect(r Rect) Vec {
  	// Check if either end of the line segment are within the rectangle
  	if r.Contains(l.A) || r.Contains(l.B) {
  		// Use the Rect.Intersect to get minimal return value
  		rIntersect := l.Bounds().Intersect(r)
  		if rIntersect.H() > rIntersect.W() {
  			// Go vertical
  			return V(0, rIntersect.H())
  		}
  		return V(rIntersect.W(), 0)
  	}
  
  	// Check if any of the rectangles' edges intersect with this line.
  	for _, edge := range r.Edges() {
  		if _, ok := l.Intersect(edge); ok {
  			// Get the closest points on the line to each corner, where:
  			//  - the point is contained by the rectangle
  			//  - the point is not the corner itself
  			corners := r.Vertices()
  			closest := ZV
  			closestCorner := corners[0]
  			for _, c := range corners {
  				cc := l.Closest(c)
  				if closest == ZV || (closest.Len() > cc.Len() && r.Contains(cc)) {
  					closest = cc
  					closestCorner = c
  				}
  			}
  
  			return closest.To(closestCorner)
  		}
  	}
  
  	// No intersect
  	return ZV
  }
docs: // IntersectRect will return the shortest Vec such that moving the Line by that Vec will cause  the Line and Rect to
  // no longer intesect.  If they do not intersect at all, this function will return a zero-vector.