Skip to content

Commit 9519e0f

Browse files
committed
0.1.0
1 parent 474c4ff commit 9519e0f

File tree

4 files changed

+71
-11
lines changed

4 files changed

+71
-11
lines changed

CHANGELOG.md

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Changelog
2+
All notable changes to this project will be documented in this file.
3+
4+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6+
7+
## [0.1.0] - 2023-02-27
8+
Initial release
9+
10+
[unreleased]: https://github.com/ModProg/interpolator/compare/v0.1.0...HEAD
11+
[0.1.0]: https://github.com/ModProg/interpolator/v0.1.0

Cargo.toml

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
[package]
2-
name = "template"
2+
name = "interpolator"
33
version = "0.1.0"
44
edition = "2021"
5-
categories = []
6-
description = ""
7-
keywords = []
5+
categories = ["template-engine", "value-formatting", "text-processing"]
6+
description = "runtime format strings, fully compatible with std's macros"
7+
keywords = ["text", "interpolation", "format"]
88
license = "MIT"
99
readme = "README.md"
1010
repository = "https://github.com/ModProg/template"
1111
documentation = "https://docs.rs/template"
1212

1313
[features]
14-
default = ["debug", "number", "pointer"]
14+
# default = ["debug", "number", "pointer"]
1515
debug = []
1616
number = []
1717
pointer = []

README.md

+54-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,55 @@
1-
# template
1+
# interpolator
22

3-
[![CI Status](https://github.com/ModProg/template/actions/workflows/test.yaml/badge.svg)](https://github.com/ModProg/template/actions/workflows/test.yaml)
4-
[![Documentation for `main`](https://img.shields.io/badge/docs-main-informational)](https://modprog.github.io/template/template/)
5-
<!-- [![Crates.io](https://img.shields.io/crates/v/template)](https://crates.io/crates/template) -->
6-
<!-- [![Docs.rs](https://img.shields.io/crates/v/template?color=informational&label=docs.rs)](https://docs.rs/template) -->
3+
[![CI Status](https://github.com/ModProg/interpolator/actions/workflows/test.yaml/badge.svg)](https://github.com/ModProg/interpolator/actions/workflows/test.yaml)
4+
[![Documentation for `main`](https://img.shields.io/badge/docs-main-informational)](https://modprog.github.io/interpolator/interpolator/)
5+
[![Crates.io](https://img.shields.io/crates/v/interpolator)](https://crates.io/crates/interpolator)
6+
[![Docs.rs](https://img.shields.io/crates/v/interpolator?color=informational&label=docs.rs)](https://docs.rs/interpolator)
7+
8+
Runtime implementation of `format!`.
9+
10+
# `format`
11+
Runtime version of `format!`.
12+
13+
Takes a string and a context, containing `Formattable` values, returns a
14+
string.
15+
16+
```rs
17+
use template::{format, Formattable};
18+
19+
let formatted = format(
20+
"{value:+05}", // could be dynamic
21+
&[("value", Formattable::display(&12))].into_iter().collect(),
22+
)
23+
.unwrap();
24+
25+
assert_eq!(formatted, format!("{:+05}", 12));
26+
```
27+
28+
# `write`
29+
Runtime version of `write!`.
30+
31+
Takes a mutable `Write` e.g. `&mut String`, a format string and a context,
32+
containing `Formattable` values.
33+
34+
```rs
35+
use template::{write, Formattable};
36+
37+
let mut buf = String::new();
38+
write(
39+
&mut buf,
40+
"{value:+05}", // could be dynamic
41+
&[("value", Formattable::display(&12))].into_iter().collect(),
42+
)
43+
.unwrap();
44+
45+
assert_eq!(buf, format!("{:+05}", 12));
46+
```
47+
48+
# Features
49+
By default only `Display` is supported, the rest of the
50+
[formatting traits](https://doc.rust-lang.org/std/fmt/index.html#formatting-traits)
51+
can be enabled through the following features.
52+
53+
- `debug` enables `?`, `x?` and `X?` trait specifiers
54+
- `number` enables `x`, `X`, `b`, `o`, `e` and `E` trait specifiers
55+
- `pointer` enables `p` trait specifiers

src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ impl<'a> FormatArgument<'a> {
496496

497497
/// Runtime version of [`write!`].
498498
///
499-
/// Takes a mutable [`Write`] e.g `&mut String`, a format string and a context,
499+
/// Takes a mutable [`Write`] e.g. `&mut String`, a format string and a context,
500500
/// containing [`Formattable`] values.
501501
///
502502
/// ```

0 commit comments

Comments
 (0)