Skip to content

Commit 8124357

Browse files
authored
fix examples & add ci for running examples (#19)
1 parent d76a821 commit 8124357

File tree

6 files changed

+12
-9
lines changed

6 files changed

+12
-9
lines changed

.github/workflows/check-test.yaml

+5
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ jobs:
2222
run: cargo clippy --all-targets --all-features
2323
- name: Run tests
2424
run: cargo test
25+
- name: Run examples
26+
run: |
27+
for example in $(ls examples/ | sed 's/\.rs$//'); do
28+
cargo run --example $example
29+
done
2530
2631
semver:
2732
runs-on: ubuntu-latest

examples/detach.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ async fn main() {
5353
tokio::spawn(root.instrument(work(rx)));
5454

5555
sleep(Duration::from_millis(100)).await;
56-
let tree = registry.get(&()).unwrap().to_string();
56+
let tree = registry.get(()).unwrap().to_string();
5757

5858
// work [106.290ms]
5959
// select [106.093ms]
@@ -62,7 +62,7 @@ async fn main() {
6262
println!("{tree}");
6363

6464
sleep(Duration::from_secs(1)).await;
65-
let tree = registry.get(&()).unwrap().to_string();
65+
let tree = registry.get(()).unwrap().to_string();
6666

6767
// work [1.112s]
6868
// rx [606.944ms]
@@ -72,7 +72,7 @@ async fn main() {
7272

7373
tx.send(()).unwrap();
7474
sleep(Duration::from_secs(1)).await;
75-
let tree = registry.get(&()).unwrap().to_string();
75+
let tree = registry.get(()).unwrap().to_string();
7676

7777
// work [2.117s]
7878
// fut [2.117s]

examples/verbose.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ async fn work(verbose: bool) -> String {
3232
tokio::spawn(root.instrument(foo()));
3333

3434
sleep(Duration::from_secs(1)).await;
35-
registry.get(&()).unwrap().to_string()
35+
registry.get(()).unwrap().to_string()
3636
}
3737

3838
#[tokio::main]

rust-toolchain

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.74
1+
1.82

src/registry.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,8 @@ impl Registry {
186186
///
187187
/// 1. If the current task is registered with a registry, returns the registry.
188188
/// 2. If the global registry is initialized with
189-
/// [`init_global_registry`](crate::global::init_global_registry), returns the global
190-
/// registry.
189+
/// [`init_global_registry`](crate::global::init_global_registry), returns the global
190+
/// registry.
191191
/// 3. Otherwise, returns `None`.
192192
pub fn try_current() -> Option<Self> {
193193
crate::root::current_registry()

src/tests.rs

-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,5 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
#![cfg(test)]
16-
1715
mod functionality;
1816
mod spawn;

0 commit comments

Comments
 (0)