mojo
mojo copied to clipboard
[stdlib] Add format_simple() for StringLiteral
Provides a "small" fix for https://github.com/modularml/mojo/issues/2761
It is not very advanced, just a small useful feature to provide:
"{name} is awesome {emoji}".format_simple(name="Mojo", emoji="🔥")
**kwargs
can't be parametrized on trait yet,
but it works by building on top on implicit conversion combined to:
String.__init__[stringable: Stringable](inout self, value: stringable):
The combination of theses two features makes this example works:
"Is {number} even? {result}".format_simple(number=2, result=True)