Skip to content

Commit 113846e

Browse files
committed
initial commit
0 parents  commit 113846e

File tree

12 files changed

+997
-0
lines changed

12 files changed

+997
-0
lines changed

.editorconfig

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
root = true
2+
3+
[*]
4+
indent_style = tab
5+
trim_trailing_whitespace = true
6+
insert_final_newline = true

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* text=auto eol=lf

.github/workflows/code-quality.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: 📋 Code Quality
2+
on:
3+
workflow_dispatch:
4+
push:
5+
branches:
6+
- 'main'
7+
paths:
8+
- '.github/workflows/code-quality.yml'
9+
- 'src/**/*.rs'
10+
- 'Cargo.toml'
11+
pull_request:
12+
paths:
13+
- '.github/workflows/code-quality.yml'
14+
- 'src/**/*.rs'
15+
- 'Cargo.toml'
16+
env:
17+
RUST_BACKTRACE: 1
18+
jobs:
19+
lint-and-fmt:
20+
name: Lint & format
21+
runs-on: ubuntu-24.04
22+
if: github.event.pull_request.draft == false
23+
steps:
24+
- name: Checkout sources
25+
uses: actions/checkout@v4
26+
- name: Install Rust
27+
uses: dtolnay/rust-toolchain@nightly
28+
with:
29+
toolchain: nightly-2024-11-10
30+
components: rustfmt, clippy
31+
- name: Check fmt
32+
run: cargo fmt --all -- --check
33+
- name: Run clippy
34+
run: cargo clippy

.github/workflows/test.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: 🧪 Cargo Tests
2+
on:
3+
workflow_dispatch:
4+
push:
5+
branches:
6+
- 'main'
7+
paths:
8+
- '.github/workflows/test.yml'
9+
- 'src/**/*.rs'
10+
- 'Cargo.toml'
11+
pull_request:
12+
paths:
13+
- '.github/workflows/test.yml'
14+
- 'src/**/*.rs'
15+
- 'Cargo.toml'
16+
env:
17+
RUST_BACKTRACE: 1
18+
jobs:
19+
test:
20+
name: Run tests
21+
runs-on: ubuntu-24.04
22+
steps:
23+
- uses: actions/checkout@v4
24+
- name: Install stable Rust toolchain
25+
uses: dtolnay/rust-toolchain@stable
26+
with:
27+
toolchain: stable
28+
- uses: Swatinem/rust-cache@v1
29+
- name: Run tests
30+
run: cargo test
31+
test-no-std:
32+
name: Run tests (unstable-thread-local)
33+
runs-on: ubuntu-24.04
34+
steps:
35+
- uses: actions/checkout@v4
36+
- name: Install stable Rust toolchain
37+
uses: dtolnay/rust-toolchain@stable
38+
with:
39+
toolchain: nightly-2024-11-10
40+
- uses: Swatinem/rust-cache@v1
41+
- name: Run tests
42+
run: cargo test --features unstable-thread-local

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/target
2+
/Cargo.lock

Cargo.toml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
[package]
2+
name = "async-stream-lite"
3+
version = "0.1.0"
4+
edition = "2021"
5+
rust-version = "1.65"
6+
license = "MIT"
7+
authors = [ "Carson M <carson@pyke.io>" ]
8+
description = "Proc macro-free async/await Rust streams"
9+
repository = "https://github.com/pykeio/async-stream-lite"
10+
11+
[dependencies]
12+
futures-core = "0.3"
13+
pin-project-lite = "0.2"
14+
15+
[dev-dependencies]
16+
tokio = { version = "1", features = [ "full", "macros" ] }
17+
futures = "0.3"
18+
19+
[features]
20+
unstable-thread-local = []

LICENSE

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
Copyright (c) 2024 pyke.io
2+
3+
Permission is hereby granted, free of charge, to any
4+
person obtaining a copy of this software and associated
5+
documentation files (the "Software"), to deal in the
6+
Software without restriction, including without
7+
limitation the rights to use, copy, modify, merge,
8+
publish, distribute, sublicense, and/or sell copies of
9+
the Software, and to permit persons to whom the Software
10+
is furnished to do so, subject to the following
11+
conditions:
12+
13+
The above copyright notice and this permission notice
14+
shall be included in all copies or substantial portions
15+
of the Software.
16+
17+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
18+
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
19+
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
20+
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
21+
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
22+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
24+
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25+
DEALINGS IN THE SOFTWARE.
26+
27+
Copyright (c) 2019 Carl Lerche
28+
29+
Permission is hereby granted, free of charge, to any
30+
person obtaining a copy of this software and associated
31+
documentation files (the "Software"), to deal in the
32+
Software without restriction, including without
33+
limitation the rights to use, copy, modify, merge,
34+
publish, distribute, sublicense, and/or sell copies of
35+
the Software, and to permit persons to whom the Software
36+
is furnished to do so, subject to the following
37+
conditions:
38+
39+
The above copyright notice and this permission notice
40+
shall be included in all copies or substantial portions
41+
of the Software.
42+
43+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
44+
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
45+
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
46+
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
47+
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
48+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
49+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
50+
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
51+
DEALINGS IN THE SOFTWARE.
52+
53+
Copyright (c) 2018 David Tolnay
54+
55+
Permission is hereby granted, free of charge, to any
56+
person obtaining a copy of this software and associated
57+
documentation files (the "Software"), to deal in the
58+
Software without restriction, including without
59+
limitation the rights to use, copy, modify, merge,
60+
publish, distribute, sublicense, and/or sell copies of
61+
the Software, and to permit persons to whom the Software
62+
is furnished to do so, subject to the following
63+
conditions:
64+
65+
The above copyright notice and this permission notice
66+
shall be included in all copies or substantial portions
67+
of the Software.
68+
69+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
70+
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
71+
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
72+
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
73+
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
74+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
75+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
76+
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
77+
DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# `async-stream-lite`
2+
It's [`async-stream`](https://lib.rs/crates/async-stream), but without proc macros.
3+
4+
```rs
5+
use async_stream_lite::async_stream;
6+
7+
use futures_util::{pin_mut, stream::StreamExt};
8+
9+
#[tokio::main]
10+
async fn main() {
11+
let stream = async_stream(|r#yield| async move {
12+
for i in 0..3 {
13+
r#yield(i).await;
14+
}
15+
});
16+
pin_mut!(stream);
17+
while let Some(value) = stream.next().await {
18+
println!("got {}", value);
19+
}
20+
}
21+
```
22+
23+
## `#![no_std]` support
24+
`async-stream-lite` supports `#![no_std]` on nightly Rust (due to the usage of [the unstable `#[thread_local]` attribute](https://doc.rust-lang.org/beta/unstable-book/language-features/thread-local.html)). To enable `#![no_std]` support, enable the `unstable-thread-local` feature.

rustfmt.toml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
edition = "2021"
2+
style_edition = "2024"
3+
unstable_features = true
4+
5+
max_width = 160
6+
hard_tabs = true
7+
tab_spaces = 4
8+
newline_style = "Unix"
9+
10+
wrap_comments = true
11+
format_code_in_doc_comments = true
12+
comment_width = 120
13+
doc_comment_code_block_width = 120
14+
normalize_comments = true
15+
16+
use_small_heuristics = "Off"
17+
fn_call_width = 140
18+
attr_fn_like_width = 112
19+
struct_lit_width = 36
20+
struct_variant_width = 60
21+
array_width = 120
22+
chain_width = 90
23+
single_line_if_else_max_width = 96
24+
25+
reorder_imports = true
26+
group_imports = "StdExternalCrate"
27+
imports_granularity = "Crate"
28+
reorder_modules = true
29+
trailing_comma = "Never"
30+
match_block_trailing_comma = false
31+
format_macro_bodies = true
32+
use_try_shorthand = true
33+
use_field_init_shorthand = true
34+
merge_derives = true
35+
force_explicit_abi = true

0 commit comments

Comments
 (0)