Skip to content

Commit 4137526

Browse files
author
Mikhail Vasilyev
committed
reorg and rename
1 parent 9db1fd9 commit 4137526

11 files changed

Lines changed: 28 additions & 24 deletions

File tree

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "local_async_utils"
3-
version = "0.1.1"
3+
version = "0.2.0"
44
edition = "2021"
55
authors = ["Mikhail Vasilyev"]
66
description = "Utilities for single-threaded async programming"

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
pub mod local_sync;
21
pub mod sealed;
32
pub mod shared;
43
pub mod stopwatch;
4+
pub mod sync;
55
pub mod time;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::shared::Shared;
1+
use super::Shared;
22
use std::cell::RefCell;
33
use std::rc::Rc;
44

src/shared/mod.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
pub mod local_shared;
2+
pub mod projected_shared;
3+
4+
use projected_shared::ProjectedShared;
5+
6+
pub trait Shared: Clone {
7+
type Target;
8+
9+
fn with<R, F>(&mut self, f: F) -> R
10+
where
11+
F: FnOnce(&mut Self::Target) -> R;
12+
13+
fn project<To, Proj>(&self, f: Proj) -> ProjectedShared<Self, Proj>
14+
where
15+
Proj: Fn(&mut Self::Target) -> &mut To + Clone,
16+
{
17+
ProjectedShared {
18+
inner: self.clone(),
19+
proj_fn: f,
20+
}
21+
}
22+
}

src/shared.rs renamed to src/shared/projected_shared.rs

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,8 @@
1-
pub trait Shared: Clone {
2-
type Target;
3-
4-
fn with<R, F>(&mut self, f: F) -> R
5-
where
6-
F: FnOnce(&mut Self::Target) -> R;
7-
8-
fn project<To, Proj>(&self, f: Proj) -> ProjectedShared<Self, Proj>
9-
where
10-
Proj: Fn(&mut Self::Target) -> &mut To + Clone,
11-
{
12-
ProjectedShared {
13-
inner: self.clone(),
14-
proj_fn: f,
15-
}
16-
}
17-
}
1+
use super::Shared;
182

193
pub struct ProjectedShared<T, F> {
20-
inner: T,
21-
proj_fn: F,
4+
pub(super) inner: T,
5+
pub(super) proj_fn: F,
226
}
237

248
impl<From, To, Inner, Proj> Shared for ProjectedShared<Inner, Proj>
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
pub mod channel;
22
pub mod condvar;
3-
pub mod local_shared;
43
pub mod oneshot;
54
pub mod semaphore;
65
mod shared_state;
76

87
pub use channel::channel;
98
pub use condvar::condvar;
10-
pub use local_shared::LocalShared;
119
pub use oneshot::oneshot;
1210
pub use semaphore::semaphore;

0 commit comments

Comments
 (0)