| 1 | # sprintf-rs |
| 2 | |
| 3 | **a clone of C sprintf in Rust** |
| 4 | |
| 5 | This crate was created out of a desire to provide C printf-style formatting |
| 6 | in a WASM program, where there is no libc. |
| 7 | |
| 8 | **Note:** *You're probably better off using standard Rust string formatting |
| 9 | instead of this crate unless you specificaly need printf compatibility.* |
| 10 | |
| 11 | This crate implements a dynamically type-checked function `vsprintf` and macro |
| 12 | `sprintf!`. |
| 13 | |
| 14 | Usage example: |
| 15 | |
| 16 | ```rust |
| 17 | use sprintf::sprintf; |
| 18 | let s = sprintf!("%d + %d = %d\n", 3, 9, 3+9).unwrap(); |
| 19 | assert_eq!(s, "3 + 9 = 12\n"); |
| 20 | ``` |
| 21 | |
| 22 | `libc` is a dev dependency as it is used in the tests to compare results. `std` |
| 23 | is used for some maths functions. |