py_fstr 0.1.0

A macro for making Python like fstrings
Documentation
  • Coverage
  • 0%
    0 out of 2 items documented0 out of 1 items with examples
  • Size
  • Source code size: 6.15 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 254.21 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 3s Average build duration of successful builds.
  • all releases: 3s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • Documentation
  • Repository
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • AharonSambol

Python fString Macro

Macro for Python-like f-strings in Rust.

Basically just the format! macro but lets you put any expression in the braces

Python:

def add_one(i: int) -> int:
    return i + 1

def main():
    b = 3
    a = f"awow look { add_one(b * 2) }!"
    print(a)

Rust equivalent:

use py_fstr::f;

fn add_one(i: i32) -> i32 {
    i + 1
}

fn main() {
    let b = 3;
    let a = f!("awow look { add_one(b * 2) }!");
    println!("{a}");
}

Install

Add the following line to your Cargo.toml file:

py_fstr = "0.1.0"