Improve the README of the printf crate

This commit is contained in:
Peter Ammon 2024-09-23 11:13:57 -07:00
parent 308ed62d83
commit 4e8d6b1760
No known key found for this signature in database
3 changed files with 6 additions and 6 deletions

2
Cargo.lock generated
View File

@ -110,7 +110,7 @@ dependencies = [
[[package]]
name = "fish-printf"
version = "0.2.0"
version = "0.2.1"
dependencies = [
"libc",
"widestring",

View File

@ -1,7 +1,7 @@
[package]
name = "fish-printf"
edition = "2021"
version = "0.2.0"
version = "0.2.1"
repository = "https://github.com/fish-shell/fish-shell"
description = "printf implementation, based on musl"
license = "MIT"

View File

@ -10,8 +10,6 @@ Licensed under the MIT license.
Run `cargo add fish-printf` to add this crate to your `Cargo.toml` file.
Also run `cargo add widestring` to add the widestring crate.
### Notes
fish-printf attempts to match the C standard for printf. It supports the following features:
@ -27,7 +25,7 @@ The size of integer values is taken from the argument type.
fish-printf can output to an `std::fmt::Write` object, or return a string.
For reasons related to fish-shell, fish-printf has a feature "widestring" which uses the [widestring](https://crates.io/crates/widestring) crate. This is off by default.
For reasons related to fish-shell, fish-printf has a feature "widestring" which uses the [widestring](https://crates.io/crates/widestring) crate. This is off by default. If enabled, run `cargo add widestring` to add the widestring crate.
### Examples
@ -38,6 +36,8 @@ use fish_printf::sprintf;
let s = sprintf!("%0.5g", 123456.0) // 1.2346e+05
// Append to an existing string.
let s = String::new();
let mut s = String::new();
sprintf!(=> &mut s, "%0.5g", 123456.0) // 1.2346e+05
```
See the crate documentation for additional examples.