Skip to content

Commit

Permalink
chore: rename picocolors-rs => picocolors
Browse files Browse the repository at this point in the history
  • Loading branch information
SoonIter committed Jan 12, 2024
1 parent f64f1d8 commit e87178e
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "picocolors_rs"
name = "picocolors"
description = "rust version of picocolors"
keywords = ["cli", "colors"]
version = "0.1.0"
Expand Down
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
# picocolors_rs
# picocolors

[![crates-io](https://badgen.net/crates/v/picocolors_rs)](https://crates.io/crates/picocolors_rs)
rust version of picocolors

[![crates-io](https://badgen.net/crates/v/picocolors_rs)](https://crates.io/crates/picocolors)

```rust
use picocolors_rs::{bg_black, bold};
use picocolors::{bg_black, bold};

fn main() {
println!("hello {}", bold(bg_black("world")));
}
```
```
2 changes: 1 addition & 1 deletion benches/bench.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use criterion::{criterion_group, criterion_main, Criterion};
use picocolors_rs::{bg_black, formatter as formatter_inline};
use picocolors::{bg_black, formatter as formatter_inline};

fn main_bench(b: &mut Criterion) {
let mut group = b.benchmark_group("benchmark");
Expand Down
7 changes: 5 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
pub fn formatter(s1: &'static str, s2: &'static str) -> impl Fn(&str) -> String {
move |text: &str| format!("{}{}{}", s1, text, s2)
pub fn formatter<T>(s1: &'static str, s2: &'static str) -> impl Fn(T) -> String
where
T: AsRef<str>,
{
move |t: T| format!("{}{}{}", s1, t.as_ref(), s2)
}

macro_rules! make_color {
Expand Down
5 changes: 4 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
use picocolors_rs::{bg_black, bold};
use picocolors::{bg_black, bold, formatter};
fn main() {
println!("hello {}", bold(bg_black("world")));

let my_custom_blue = formatter("\x1b[0m", "\x1b[0m");
println!("hello {:?}", my_custom_blue("world"));
}
2 changes: 1 addition & 1 deletion tests/colors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ macro_rules! make_test {
$(
#[test]
fn $name() {
use picocolors_rs::$name;
use picocolors::$name;
let color1: String = $name("I am a string.");
let color2: String = $name("I am a string.".to_string());
assert_eq!(color1, color2);
Expand Down

0 comments on commit e87178e

Please sign in to comment.