Skip to content

Commit

Permalink
chore: rename crate
Browse files Browse the repository at this point in the history
  • Loading branch information
MingweiSamuel committed Sep 12, 2024
1 parent 4d40126 commit ab0422f
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 19 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

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

9 changes: 4 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
[package]
name = "match_deref"
version = "0.1.1"
name = "matchbox"
version = "0.0.0"
edition = "2021"
license = "MIT OR Apache-2.0"
description = "Deref patterns in \"match\" for stable Rust. Now you can match through Rc, String, etc"
homepage = "https://sr.ht/~safinaskar/match_deref-rs"
repository = "https://git.sr.ht/~safinaskar/match_deref-rs"
description = "`box` and deref patterns in \"match\" for stable Rust. Now you can match through `Box`, `Rc`, etc."
repository = "https://github.com/hydro-project/matchbox"

[lib]
proc-macro = true
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
`Deref` patterns in `match` for stable Rust. Now you can match through `Rc`, `String`, etc.

`match_deref::match_deref!{...}` is a procedural macro, which allows you to use deref patterns right now in stable Rust.
`matchbox::match_deref!{...}` is a procedural macro, which allows you to use deref patterns right now in stable Rust.

For example:
```rust
Expand All @@ -15,7 +15,7 @@ enum Value {
use Value::*;

let v: &Value = todo!();
match_deref::match_deref!{
matchbox::match_deref!{
match v {
Nil => todo!(),
Cons(Deref @ Symbol(Deref @ "quote"), Deref @ Cons(x, Deref @ Nil)) => todo!(),
Expand All @@ -34,7 +34,7 @@ The macro calls `Deref::deref` internally. Keep in mind that `Deref::deref` take

Consider this code:
```rust
match_deref::match_deref!{
matchbox::match_deref!{
match v {
Symbol(Deref @ x) => some_code_here,
_ => other_code_here,
Expand Down
18 changes: 9 additions & 9 deletions tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ fn tests() {
Symbol(String),
}
use LispValue::*;
let _: i32 = match_deref::match_deref!{
let _: i32 = matchbox::match_deref!{
match &Nil {
Nil => 0,
Cons(Deref @ _, Deref @ Nil) => 0,
Expand All @@ -19,26 +19,26 @@ fn tests() {
Symbol(_) => 0,
}
};
assert_eq!(match_deref::match_deref!{
assert_eq!(matchbox::match_deref!{
match &Cons(Rc::new(Symbol("a".to_owned())), Rc::new(Nil)) {
Cons(Deref @ Symbol(Deref @ "a"), _) => 1,
_ => 0
}
}, 1);
assert_eq!(match_deref::match_deref!{
assert_eq!(matchbox::match_deref!{
match &Cons(Rc::new(Symbol("a".to_owned())), Rc::new(Nil)) {
Cons(Deref @ Symbol(Deref @ "b"), _) => 1,
_ => 0
}
}, 0);
assert_eq!(match_deref::match_deref!{
assert_eq!(matchbox::match_deref!{
match &Cons(Rc::new(Symbol("a".to_owned())), Rc::new(Nil)) {
Cons(Deref @ Symbol(Deref @ "a"), Deref @ x) => x,
_ => panic!()
}
}, &Nil);
assert_eq!((||{
let _: i32 = match_deref::match_deref!{
let _: i32 = matchbox::match_deref!{
match &Cons(Rc::new(Symbol("a".to_owned())), Rc::new(Nil)) {
Cons(Deref @ Symbol(Deref @ "a"), Deref @ x) => return x.clone(),
_ => 0
Expand All @@ -48,14 +48,14 @@ fn tests() {
})(), Nil);
{
let a0 = 0;
assert_eq!(match_deref::match_deref!{
assert_eq!(matchbox::match_deref!{
match &Rc::new(Nil) {
Deref @ _ => a0,
_ => panic!()
}
}, 0);
}
match_deref::match_deref!{
matchbox::match_deref!{
match &Cons(Rc::new(Nil), Rc::new(Nil)) {
Cons(a @ Deref @ b @ Nil, _) => {
assert_eq!(a, &Rc::new(Nil));
Expand All @@ -64,9 +64,9 @@ fn tests() {
_ => panic!(),
}
}
assert_eq!(match_deref::match_deref!{
assert_eq!(matchbox::match_deref!{
match &Cons(Rc::new(Cons(Rc::new(Nil), Rc::new(Nil))), Rc::new(Nil)) {
Cons(Deref @ a, _) => match_deref::match_deref! {
Cons(Deref @ a, _) => matchbox::match_deref! {
match a {
Cons(Deref @ Nil, _) => 5,
_ => panic!(),
Expand Down

0 comments on commit ab0422f

Please sign in to comment.