Skip to content

Commit c8d6daf

Browse files
committed
feat: v2.0.0
1 parent 99def69 commit c8d6daf

File tree

4 files changed

+39
-10
lines changed

4 files changed

+39
-10
lines changed

Cargo.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "clonelicious"
3-
version = "1.1.1"
3+
version = "2.0.0"
44
edition = "2024"
55
authors = ["ltpp-universe <root@ltpp.vip>"]
66
license = "MIT"
@@ -15,6 +15,9 @@ exclude = [
1515
".github"
1616
]
1717

18+
[dev-dependencies]
19+
tokio = { version = "1.45.0", features = ["full"] }
20+
1821
[profile.dev]
1922
incremental = false
2023
opt-level = 3

readme.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,25 @@ cargo add clonelicious
2626

2727
```rust
2828
use clonelicious::*;
29+
2930
let s1: String = String::from("Hello");
3031
let s2: String = String::from("World");
31-
let res: String = clone!(s1, s2, {
32+
let res: String = clone!(s1, s2 => {
3233
assert_eq!(s1, String::from("Hello"));
3334
assert_eq!(s2, String::from("World"));
3435
format!("{} {}", s1, s2)
3536
});
3637
assert_eq!(res, String::from("Hello World"));
38+
39+
let s1: String = String::from("Hello");
40+
let s2: String = String::from("World");
41+
let res: String = clone!(s1, s2 => async move {
42+
assert_eq!(s1, String::from("Hello"));
43+
assert_eq!(s2, String::from("World"));
44+
format!("{} {}", s1, s2)
45+
})
46+
.await;
47+
assert_eq!(res, String::from("Hello World"));
3748
```
3849

3950
## License

src/cfg.rs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,24 @@
1-
#[test]
2-
fn test_clone() {
1+
#[cfg(test)]
2+
#[tokio::test]
3+
async fn test_clone() {
34
use crate::*;
5+
46
let s1: String = String::from("Hello");
57
let s2: String = String::from("World");
6-
let res: String = clone!(s1, s2, {
8+
let res: String = clone!(s1, s2 => {
79
assert_eq!(s1, String::from("Hello"));
810
assert_eq!(s2, String::from("World"));
911
format!("{} {}", s1, s2)
1012
});
1113
assert_eq!(res, String::from("Hello World"));
14+
15+
let s1: String = String::from("Hello");
16+
let s2: String = String::from("World");
17+
let res: String = clone!(s1, s2 => async move {
18+
assert_eq!(s1, String::from("Hello"));
19+
assert_eq!(s2, String::from("World"));
20+
format!("{} {}", s1, s2)
21+
})
22+
.await;
23+
assert_eq!(res, String::from("Hello World"));
1224
}

src/macro.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,13 @@
2020
/// but don't want to manually clone each value before passing it into the closure.
2121
#[macro_export]
2222
macro_rules! clone {
23-
( $( $var:ident ),*, $body:block ) => {{
24-
$(
25-
let $var = $var.clone();
26-
)*
27-
$body
23+
( $( $var:ident ),* => { $($body:tt)* } ) => {{
24+
$( let $var = $var.clone(); )*
25+
{ $($body)* }
26+
}};
27+
28+
( $( $var:ident ),* => async move { $($body:tt)* } ) => {{
29+
$( let $var = $var.clone(); )*
30+
async move { $($body)* }
2831
}};
2932
}

0 commit comments

Comments
 (0)