Algorithm that accepts a path as an InputRange and a file extension as an InputRange,
and returns an InputRange that produces a char string containing the path given
by path, but where
the extension has been set to ext.

If the filename already has an extension, it is replaced. If not, the
extension is simply appended to the filename. Including a leading dot
in ext is optional.

If the extension is empty, this function produces the equivalent of
stripExtension applied to path.

The algorithm is lazy, does not allocate, does not throw, and is pure.