The problem is that almost every client method would have to manipulate URL, e.g. add path segments, but these methods may return error for 'cannot-be-base' URLs. So you either have to propagate this error or use unwrap, both ways are so-so.
It would be convenient to have separate type for URLs which are always can-be-base. You convert URL to this BaseURL once, pass it to client and client is sure that URL-manipulation methods are infallible.
Suppose you write client for some REST service:
The problem is that almost every client method would have to manipulate URL, e.g. add path segments, but these methods may return error for 'cannot-be-base' URLs. So you either have to propagate this error or use
unwrap
, both ways are so-so.It would be convenient to have separate type for URLs which are always can-be-base. You convert URL to this BaseURL once, pass it to client and client is sure that URL-manipulation methods are infallible.