Closed Ethosa closed 10 months ago
this makes copies, though
this makes copies, though
Maybe Nim allows to destruct object
? 🤔
cast[Regex](regex2)
is also forbidden by Nim VM
@nitely please see changes
@nitely please check again
I think the point of using converters is you don't need to call them. There is an implicit call, like here. If you are calling them, then just use a template.
FYI, one way to avoid copies when there are two compatible types like this, is to define something like type RegexT = Regex | Regex2
and use it internally, so you can pass any of those two types. But I see you are only copying on JS, which I don't mind because JS is slow anyway, and if someone cares about performance in JS they should use the native JS regex.
Also, this is really a Nim regression, and it would be better if the compiler gets fixed/backported. But if tests pass, I'll merge it.
So, I just remove
distinct
keyword. Also I created procedurestoRegex(Regex2)
andtoRegex2(Regex)
for convert.