Skip to content

Commit

Permalink
1. Remove travis.yml
Browse files Browse the repository at this point in the history
2. Update package description
3. Bump package version to `1.2.0`
4. Refactor `readme.md`
5. Rename some examples
6. Remove `run_enc`, `run_enclose` macros, [] is easier to type than `enclose()` for small tests
7. Document many macros
8. Allow trailing comma in `enc`, `enclose` macro
9. Update tests
10. Simplify `enc`, `enclose`, `enclose_var` macros
  • Loading branch information
denisandroid committed May 18, 2024
1 parent 0264d4c commit 1a78797
Show file tree
Hide file tree
Showing 31 changed files with 804 additions and 1,180 deletions.
14 changes: 14 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# EditorConfig helps developers define and maintain consistent
# coding styles between different editors and IDEs
# http://editorconfig.org

root = true

[*.rs]
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = false
insert_final_newline = false
indent_style = tab
indent_size = 5
max_line_length = 80
16 changes: 0 additions & 16 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</br></br>
</div>

## Description:
## Description

Our community is dedicated to providing a respectful and inclusive environment for everyone, regardless of gender, age, sexual orientation, disability, physical appearance, body size, race, nationality, or religion.

Expand Down
7 changes: 1 addition & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,8 @@ license = "MIT/Apache-2.0"
readme = "README.md"
edition = "2021"

description = "A convenient macro for cloning values into a closure."
description = "A convenient macro, for cloning values into a closure."
keywords = ["enclose", "enclose_macro", "macro", "no_std", "clucompany"]
categories = ["development-tools"]

[features]
default = ["disable_dep"]
disable_ext = []
disable_dep = []

[dependencies]
224 changes: 0 additions & 224 deletions LICENSE

This file was deleted.

2 changes: 1 addition & 1 deletion LICENSE_APACHE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright [yyyy] [name of copyright owner]
Copyright 2019-2024 #UlinProject (Denis Kotlyarov) Денис Котляров

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 2 additions & 0 deletions LICENSE_MIT
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
MIT License

Copyright 2019-2024 #UlinProject (Denis Kotlyarov) Денис Котляров

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
Expand Down
18 changes: 11 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<b>[enclose]</b>

(A convenient macro for cloning values into a closure.)
(A convenient macro, for cloning values into a closure.)
</br></br>

<div id="badges">
Expand Down Expand Up @@ -31,21 +31,22 @@
</div>
</div>

## Usage:
## Usage

Add this to your Cargo.toml:

```toml
[dependencies]
enclose = "1.1.8"
enclose = "1.2.0"
```

and this to your source code:

```rust
use enclose::enclose;
```

## Example:
## Example

### EasyUse

Expand Down Expand Up @@ -210,7 +211,8 @@ fn my_enclose<F: FnOnce() -> R, R>(a: F) -> R {
See all
</a>

## License:
## License

This project has a dual license according to (LICENSE-MIT) and (LICENSE-APACHE-2-0).

<div align="left">
Expand All @@ -223,7 +225,8 @@ This project has a dual license according to (LICENSE-MIT) and (LICENSE-APACHE-2
</br></br></br>
</div>

### Apache License:
### Apache License

<div align="left">
<a href="./LICENSE_APACHE">
<img align="left" src="https://github.com/UlinProject/img/blob/main/block_220_100/apache2.png?raw=true" alt="apache2"/>
Expand All @@ -233,7 +236,8 @@ This project has a dual license according to (LICENSE-MIT) and (LICENSE-APACHE-2
</br></br></br></br>
</div>

### MIT License:
### MIT License

<div align="left">
<a href="./LICENSE_MIT">
<img align="left" src="https://github.com/UlinProject/img/blob/main/block_220_100/mit.png?raw=true" alt="mit"/>
Expand Down
31 changes: 31 additions & 0 deletions examples/expr.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
use enclose::enclose;
use std::sync::Arc;

fn main() {
let clone_data = Arc::new(0);
let add_data = Arc::new(100);

// I also note that any expressions can be used, but the main thing is to
// put the @ symbol at the beginning of the variable, and not forget to assign
// a new name to the variable using =>.
my_enclose(
enclose!((@*clone_data => mut clone_data: usize, @*(add_data.clone()) => add_data) || {
// (@*clone_data => mut clone_data, @*(add_data.clone()) => add_data) ->
// let mut clone_data = *clone_data;
// let add_data = *(add_data.clone());

println!("#0 {:?}", clone_data);
clone_data += add_data;
println!("#1 {:?}", clone_data);

assert_eq!(clone_data, 100);
}),
);

assert_eq!(*clone_data, 0);
}

#[inline]
fn my_enclose<F: FnOnce() -> R, R>(a: F) -> R {
a()
}
Loading

0 comments on commit 1a78797

Please sign in to comment.