I tried to look up the definition of String.trim_leading/1 from GitHub, because I wanted to clarify the meaning of “Unicode whitespaces” in the documentation. However, all I saw was the single line
defdelegate trim_leading(string), to: String.Break
and I couldn’t find the module String.Break on GitHub or HexDocs. Does anybody know where are the actual definitions of String.trim_leading/1 or String.Break located?
See the Unicode folder: https://github.com/elixir-lang/elixir/tree/master/lib/elixir/unicode
Those modules are slow to compile, so they are in their own directory.
4 Likes
Thanks. On ll.292-294 of https://github.com/elixir-lang/elixir/blob/master/lib/elixir/unicode/properties.ex :
for codepoint <- whitespace do
def do_trim_leading(<<unquote(codepoint), rest::bits>>), do: do_trim_leading(rest)
end
This is cool… I didn’t know one can generate functions programatically like this at compile time!
3 Likes