Interpolate

A simple form of Rust string interpolation, e.g., s!("Today is {date}").

Documentation

Crates.io

Usage

Note: interpolate currently requires some experimental functionality in nightly.

```rust

![feature(useexternmacros, proc_macro)]

use interpolate::s;

let name = "Jane"; let favnum = 32; let greeting = s!("{name}'s favorite number is {favnum}"); ```

Escaping braces is accomplished similar to escaping other format strings in rust.

The literal characters { and } may be included in a string by preceding them with the same character. For example, the { character is escaped with {{ and the } character is escaped with }}.

Idea

The goal of interpolate is to provide basic string interpolation functionality with a very light-weight syntax.

It is not:

I created this after a working on a CLI tools where I used format! a LOT. I really wanted something lighter weight like Scala's s"Today is $date", so I decided to experiment here, with the idea of possibly adding to the discussions around strings (like allowing literals to be used as String and custom string literals. I frequently find myself wondering if any of these ideas could have a more central role in rust: