Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#![no_std] support #100

Merged
merged 7 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 65 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 8 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ repository = "https://github.com/actuate-rs/actuate"
[features]
animation = ["ecs", "dep:bevy_math", "dep:bevy_time"]
ecs = ["dep:bevy_app", "dep:bevy_ecs", "dep:bevy_hierarchy", "dep:bevy_utils"]
executor = []
executor = ["std", "dep:tokio"]
rt = ["executor", "tokio/rt-multi-thread"]
std = []
tracing = ["dep:tracing"]
full = ["animation", "ecs", "rt", "tracing"]
default = []
default = ["std"]

[workspace]
members = [
Expand All @@ -23,16 +24,20 @@ members = [

[dependencies]
actuate-macros = { version = "0.1.6", path = "macros" }
ahash = { version = "0.8.11", default-features = false }
bevy_app = { version = "0.15.0", optional = true }
bevy_ecs = { version = "0.15.0", optional = true }
bevy_hierarchy = { version = "0.15.0", optional = true }
bevy_math = { version = "0.15.0", optional = true }
bevy_time = { version = "0.15.0", optional = true }
bevy_utils = { version = "0.15.0", optional = true }
crossbeam-queue = { version = "0.3.11", default-features = false, features = ["alloc"] }
futures = "0.3.31"
hashbrown = "0.15.2"
slotmap = "1.0.7"
thiserror = "2.0.3"
tracing = { version = "0.1.40", optional = true }
tokio = { version = "1.41.1", features = ["sync"] }
tokio = { version = "1.41.1", features = ["sync"], optional = true }
typeid = "1.0.2"

[dev-dependencies]
Expand Down
5 changes: 3 additions & 2 deletions examples/core/composer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ fn main() {
.unwrap();

let mut composer = Composer::new(App);
composer.compose().unwrap();
composer.compose().unwrap();
composer.try_compose().unwrap().unwrap();

assert!(composer.try_compose().is_none());
}
2 changes: 1 addition & 1 deletion examples/core/error_handling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@ fn main() {
.unwrap();

let mut composer = Composer::new(App);
assert!(composer.compose().is_ok());
assert!(composer.try_compose().unwrap().is_ok());
}
8 changes: 4 additions & 4 deletions src/animation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ struct State<T> {
}

/// Use an animated value.
pub fn use_animated<T: VectorSpace + 'static>(
cx: ScopeState,
make_initial: impl FnOnce() -> T,
) -> UseAnimated<T> {
pub fn use_animated<T>(cx: ScopeState, make_initial: impl FnOnce() -> T) -> UseAnimated<T>
where
T: VectorSpace + Send + 'static,
{
let start_cell = use_world_once(cx, |time: Res<Time>| Cell::new(Some(time.elapsed_secs())));

let (controller, rx) = use_ref(cx, || {
Expand Down
10 changes: 5 additions & 5 deletions src/compose.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::{prelude::*, Memoize, ScopeData};
use std::{
use alloc::borrow::Cow;
use core::{
any::TypeId,
borrow::Cow,
cell::{RefCell, UnsafeCell},
error::Error as StdError,
mem,
Expand Down Expand Up @@ -32,7 +32,7 @@ pub trait Compose: Data {

#[doc(hidden)]
fn name() -> Option<Cow<'static, str>> {
let name = std::any::type_name::<Self>();
let name = core::any::type_name::<Self>();
Some(
name.split('<')
.next()
Expand Down Expand Up @@ -91,7 +91,7 @@ impl<C: Compose> Compose for Option<C> {
/// This can be handled by a parent composable with [`Catch`].
#[derive(Data)]
pub struct Error {
make_error: Box<dyn Fn() -> Box<dyn std::error::Error>>,
make_error: Box<dyn Fn() -> Box<dyn core::error::Error>>,
}

impl Error {
Expand Down Expand Up @@ -483,7 +483,7 @@ where
}

unsafe fn reborrow(&mut self, ptr: *mut ()) {
std::ptr::swap(self, ptr as _);
core::ptr::swap(self, ptr as _);
}

unsafe fn any_compose(&self, state: &ScopeData) {
Expand Down
Loading
Loading