/Engine/Source/Runtime/Core/Public/Math/UnrealMathUtility.h
This is the safe version, and will check both segments' lengths. Use this if either (or both) of the segments lengths may be 0.
static void SegmentDistToSegmentSafe ( FVector A1, FVector B1, FVector A2, FVector B2, FVector & OutP1, FVector & OutP2 )