mojo icon indicating copy to clipboard operation
mojo copied to clipboard

[stdlib] Add format_simple() for StringLiteral

Open rd4com opened this issue 9 months ago • 0 comments

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)

rd4com avatar May 21 '24 14:05 rd4com