This is really just repeating what @SolitudeSF said, but you can't find the 
`string` function because it doesn't exist. A `Path` is a distinct string, so 
essentially it's already a string. `Path("/some/path")` is a type conversion 
from `string` to `Path`, and `string(myPath)` is a type conversion from `Path` 
to `string`. Neither are functions, and there's no specific implementation 
anywhere to find. You're just telling the compiler to treat the data as one 
type or the other. Basically casting the data, but type safe.

I'm not sure why `Path` doesn't provide a `$` operator, but you can tell the 
compiler to use the version from its base type (`string`) like this: `proc 
`$`*(self: Path): string {.borrow.}`.

There is a universal "turn anything into a string" function called 
[repr](https://nim-lang.org/docs/system.html#repr%2CT), but it's meant as a 
debugging tool. `$` is the default way you should turn things into strings, 
unless they're distinct strings, in which case you can use a type conversion.

Reply via email to