I have just started playing around with concepts, but I'm very confused about what this return statement is used for with the generics converters I have tried to do the exact same example and nothing seems to work. though I don't understand what should be happening anyway. Any help would be greatly appreciated.
https://nim-lang.org/docs/manual.html#generics-converter-type-classes
The feature doesn't work now, and the intended use is just automatic conversion of the matched value, as stated in that paragraph.
type A = concept x
$x is string
type B = concept x
$x is string
return $x
type C = concept x
$x is string and $x.len > 0
return $x[0]
type D = concept x
true
return "just anything"
import typetraits
# procedures are written the same, except for the type of `x`
proc a(x: A) = echo x, ": ", x.type
proc b(x: B) = echo x, ": ", x.type
proc c(x: C) = echo x, ": ", x.type
proc d(x: D) = echo x, ": ", x.type
var x = 123
a x # => 123: int
b x # => 123: string
c x # => 1: char
d x # => just anything: string