Skip to content

Commit d9297e0

Browse files
committed
gcore: replace core and alloc paths with std
1 parent 1164fd1 commit d9297e0

34 files changed

Lines changed: 185 additions & 192 deletions

node-graph/gcore/src/application_io.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
use crate::text::FontCache;
22
use crate::transform::Footprint;
33
use crate::vector::style::ViewMode;
4-
use alloc::sync::Arc;
5-
use core::fmt::Debug;
6-
use core::future::Future;
7-
use core::hash::{Hash, Hasher};
8-
use core::pin::Pin;
9-
use core::ptr::addr_of;
10-
use core::time::Duration;
114
use dyn_any::{DynAny, StaticType, StaticTypeSized};
125
use glam::{DAffine2, UVec2};
6+
use std::fmt::Debug;
7+
use std::future::Future;
8+
use std::hash::{Hash, Hasher};
9+
use std::pin::Pin;
10+
use std::ptr::addr_of;
11+
use std::sync::Arc;
12+
use std::time::Duration;
1313

1414
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1515
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
1616
pub struct SurfaceId(pub u64);
1717

18-
impl core::fmt::Display for SurfaceId {
19-
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
18+
impl std::fmt::Display for SurfaceId {
19+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2020
f.write_fmt(format_args!("{}", self.0))
2121
}
2222
}
@@ -298,7 +298,7 @@ impl<Io> PartialEq for EditorApi<Io> {
298298
}
299299

300300
impl<T> Debug for EditorApi<T> {
301-
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
301+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
302302
f.debug_struct("EditorApi").field("font_cache", &self.font_cache).finish()
303303
}
304304
}

node-graph/gcore/src/context.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::transform::Footprint;
2-
use core::any::Any;
3-
use core::borrow::Borrow;
4-
use core::panic::Location;
2+
use std::any::Any;
3+
use std::borrow::Borrow;
4+
use std::panic::Location;
55
use std::sync::Arc;
66

77
pub trait Ctx: Clone + Send {}
@@ -249,8 +249,8 @@ pub struct OwnedContextImpl {
249249
animation_time: Option<f64>,
250250
}
251251

252-
impl core::fmt::Debug for OwnedContextImpl {
253-
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
252+
impl std::fmt::Debug for OwnedContextImpl {
253+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
254254
f.debug_struct("OwnedContextImpl")
255255
.field("footprint", &self.footprint)
256256
.field("varargs", &self.varargs)
@@ -269,8 +269,8 @@ impl Default for OwnedContextImpl {
269269
}
270270
}
271271

272-
impl core::hash::Hash for OwnedContextImpl {
273-
fn hash<H: core::hash::Hasher>(&self, state: &mut H) {
272+
impl std::hash::Hash for OwnedContextImpl {
273+
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
274274
self.footprint.hash(state);
275275
self.varargs.as_ref().map(|x| Arc::as_ptr(x).addr()).hash(state);
276276
self.parent.as_ref().map(|x| Arc::as_ptr(x).addr()).hash(state);

node-graph/gcore/src/generic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::Node;
2-
use core::marker::PhantomData;
2+
use std::marker::PhantomData;
33
#[derive(Clone)]
44
pub struct FnNode<T: Fn(I) -> O, I, O>(T, PhantomData<(I, O)>);
55

node-graph/gcore/src/graphic_element.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ impl Default for AlphaBlending {
2626
Self::new()
2727
}
2828
}
29-
impl core::hash::Hash for AlphaBlending {
30-
fn hash<H: core::hash::Hasher>(&self, state: &mut H) {
29+
impl std::hash::Hash for AlphaBlending {
30+
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
3131
self.opacity.to_bits().hash(state);
3232
self.fill.to_bits().hash(state);
3333
self.blend_mode.hash(state);

node-graph/gcore/src/graphic_element/renderer.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ impl Default for SvgRender {
300300
#[derive(Clone, Debug, Default)]
301301
pub struct RenderContext {
302302
#[cfg(feature = "wgpu")]
303-
pub resource_overrides: std::collections::HashMap<u64, alloc::sync::Arc<wgpu::Texture>>,
303+
pub resource_overrides: std::collections::HashMap<u64, std::sync::Arc<wgpu::Texture>>,
304304
}
305305

306306
/// Static state used whilst rendering
@@ -1307,7 +1307,7 @@ impl GraphicElementRendered for GraphicElement {
13071307
}
13081308

13091309
/// Used to stop rust complaining about upstream traits adding display implementations to `Option<Color>`. This would not be an issue as we control that crate.
1310-
trait Primitive: core::fmt::Display {}
1310+
trait Primitive: std::fmt::Display {}
13111311
impl Primitive for String {}
13121312
impl Primitive for bool {}
13131313
impl Primitive for f32 {}

node-graph/gcore/src/graphic_element/renderer/quad.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ impl Quad {
143143
}
144144
}
145145

146-
impl core::ops::Mul<Quad> for DAffine2 {
146+
impl std::ops::Mul<Quad> for DAffine2 {
147147
type Output = Quad;
148148

149149
fn mul(self, rhs: Quad) -> Self::Output {

node-graph/gcore/src/graphic_element/renderer/rect.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,21 +97,21 @@ impl Rect {
9797
}
9898
}
9999

100-
impl core::ops::Mul<Rect> for DAffine2 {
100+
impl std::ops::Mul<Rect> for DAffine2 {
101101
type Output = super::Quad;
102102

103103
fn mul(self, rhs: Rect) -> Self::Output {
104104
self * super::Quad::from_box(rhs.0)
105105
}
106106
}
107107

108-
impl core::ops::Index<usize> for Rect {
108+
impl std::ops::Index<usize> for Rect {
109109
type Output = DVec2;
110110
fn index(&self, index: usize) -> &Self::Output {
111111
&self.0[index]
112112
}
113113
}
114-
impl core::ops::IndexMut<usize> for Rect {
114+
impl std::ops::IndexMut<usize> for Rect {
115115
fn index_mut(&mut self, index: usize) -> &mut Self::Output {
116116
&mut self.0[index]
117117
}

node-graph/gcore/src/instances.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,8 @@ impl<T> Default for Instances<T> {
128128
}
129129
}
130130

131-
impl<T: Hash> core::hash::Hash for Instances<T> {
132-
fn hash<H: core::hash::Hasher>(&self, state: &mut H) {
131+
impl<T: Hash> std::hash::Hash for Instances<T> {
132+
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
133133
for instance in &self.instance {
134134
instance.hash(state);
135135
}

node-graph/gcore/src/lib.rs

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
extern crate alloc;
2-
31
#[macro_use]
42
extern crate log;
5-
pub use crate as graphene_core;
6-
pub use num_traits;
73

4+
pub use crate as graphene_core;
85
pub use ctor;
6+
pub use num_traits;
97

108
pub mod animation;
119
pub mod consts;
@@ -34,12 +32,12 @@ pub mod application_io;
3432
pub mod registry;
3533

3634
pub use context::*;
37-
use core::any::TypeId;
38-
use core::future::Future;
39-
use core::pin::Pin;
4035
pub use dyn_any::{StaticTypeSized, WasmNotSend, WasmNotSync};
4136
pub use memo::MemoHash;
4237
pub use raster::Color;
38+
use std::any::TypeId;
39+
use std::future::Future;
40+
use std::pin::Pin;
4341
pub use types::Cow;
4442

4543
// pub trait Node: for<'n> NodeIO<'n> {
@@ -53,11 +51,11 @@ pub trait Node<'i, Input> {
5351
fn reset(&self) {}
5452
/// Returns the name of the node for diagnostic purposes.
5553
fn node_name(&self) -> &'static str {
56-
core::any::type_name::<Self>()
54+
std::any::type_name::<Self>()
5755
}
5856
/// Serialize the node which is used for the `introspect` function which can retrieve values from monitor nodes.
59-
fn serialize(&self) -> Option<std::sync::Arc<dyn core::any::Any + Send + Sync>> {
60-
log::warn!("Node::serialize not implemented for {}", core::any::type_name::<Self>());
57+
fn serialize(&self) -> Option<std::sync::Arc<dyn std::any::Any + Send + Sync>> {
58+
log::warn!("Node::serialize not implemented for {}", std::any::type_name::<Self>());
6159
None
6260
}
6361
}
@@ -74,13 +72,13 @@ where
7472
TypeId::of::<Input::Static>()
7573
}
7674
fn input_type_name(&self) -> &'static str {
77-
core::any::type_name::<Input>()
75+
std::any::type_name::<Input>()
7876
}
79-
fn output_type(&self) -> core::any::TypeId {
77+
fn output_type(&self) -> std::any::TypeId {
8078
TypeId::of::<<Self::Output as StaticTypeSized>::Static>()
8179
}
8280
fn output_type_name(&self) -> &'static str {
83-
core::any::type_name::<Self::Output>()
81+
std::any::type_name::<Self::Output>()
8482
}
8583
fn to_node_io(&self, inputs: Vec<Type>) -> NodeIOTypes {
8684
NodeIOTypes {
@@ -121,7 +119,7 @@ impl<'i, I: 'i, O: 'i, N: Node<'i, I, Output = O> + ?Sized> Node<'i, I> for Box<
121119
(**self).eval(input)
122120
}
123121
}
124-
impl<'i, I: 'i, O: 'i, N: Node<'i, I, Output = O> + ?Sized> Node<'i, I> for alloc::sync::Arc<N> {
122+
impl<'i, I: 'i, O: 'i, N: Node<'i, I, Output = O> + ?Sized> Node<'i, I> for std::sync::Arc<N> {
125123
type Output = O;
126124
fn eval(&'i self, input: I) -> O {
127125
(**self).eval(input)
@@ -147,7 +145,7 @@ pub type WasmSurfaceHandle = application_io::SurfaceHandle<web_sys::HtmlCanvasEl
147145
#[cfg(feature = "wasm")]
148146
pub type WasmSurfaceHandleFrame = application_io::SurfaceHandleFrame<web_sys::HtmlCanvasElement>;
149147

150-
pub trait InputAccessorSource<'a, T>: InputAccessorSourceIdentifier + core::fmt::Debug {
148+
pub trait InputAccessorSource<'a, T>: InputAccessorSourceIdentifier + std::fmt::Debug {
151149
fn get_input(&'a self, index: usize) -> Option<&'a T>;
152150
fn set_input(&'a mut self, index: usize, value: T);
153151
}

node-graph/gcore/src/logic.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ use crate::{Color, Context, Ctx};
33
use glam::{DAffine2, DVec2};
44

55
#[node_macro::node(category("Debug"))]
6-
fn log_to_console<T: core::fmt::Debug>(_: impl Ctx, #[implementations(String, bool, f64, u32, u64, DVec2, VectorDataTable, DAffine2, Color, Option<Color>)] value: T) -> T {
6+
fn log_to_console<T: std::fmt::Debug>(_: impl Ctx, #[implementations(String, bool, f64, u32, u64, DVec2, VectorDataTable, DAffine2, Color, Option<Color>)] value: T) -> T {
77
#[cfg(not(target_arch = "spirv"))]
88
// KEEP THIS `debug!()` - It acts as the output for the debug node itself
99
log::debug!("{:#?}", value);
1010
value
1111
}
1212

1313
#[node_macro::node(category("Text"))]
14-
fn to_string<T: core::fmt::Debug>(_: impl Ctx, #[implementations(String, bool, f64, u32, u64, DVec2, VectorDataTable, DAffine2)] value: T) -> String {
14+
fn to_string<T: std::fmt::Debug>(_: impl Ctx, #[implementations(String, bool, f64, u32, u64, DVec2, VectorDataTable, DAffine2)] value: T) -> String {
1515
format!("{:?}", value)
1616
}
1717

0 commit comments

Comments
 (0)