tur/range-string
stdlib/range-string.tur
owned String siblings for the tur/range formatters.
Since: v2 (string-adoption-stdlib-plan, batch 3)
defn
range-fmt-string
(range-fmt-string [lo-kind : int lo-val : int hi-kind : int hi-val : int] :)
render a pair of endpoint kinds/values in interval
Parameters
| lo-kind | 0 unbounded, 1 inclusive, 2 exclusive (low endpoint) | |
| lo-val | low endpoint value (ignored when unbounded) | |
| hi-kind | 0 unbounded, 1 inclusive, 2 exclusive (high endpoint) | |
| hi-val | high endpoint value (ignored when unbounded) |
Returns
An owned String, e.g. "[1, 5)".
Example
(string/to-cstr (range-fmt-string 1 1 2 5)) ; => "[1, 5)"
Since: v2
defn
range->str-string
(range->str-string [r : int] :)
render a Range in interval notation, as an owned String.
Parameters
| r | an :int Range pointer |
Returns
An owned String, e.g. "[1, 5)".
Example
(string/to-cstr (range->str-string (closed-open-range 1 5))) ; => "[1, 5)"
Since: v2
defn
bound-fmt-string
(bound-fmt-string [kind : int v : int] :)
render a single inclusive/exclusive endpoint, as an
Parameters
| kind | 1 inclusive, 2 exclusive | |
| v | the endpoint value |
Returns
An owned String, e.g. "[3" or "(3".
Example
(string/to-cstr (bound-fmt-string 1 3)) ; => "[3"
Since: v2
defn
bound-show-fmt-string
(bound-show-fmt-string [kind : int v : int] :)
render a single inclusive/exclusive endpoint (the
Parameters
| kind | 1 inclusive, 2 exclusive | |
| v | the endpoint value |
Returns
An owned String, e.g. "[3" or "(3".
Example
(string/to-cstr (bound-show-fmt-string 2 3)) ; => "(3"
Since: v2