Upgrade to the Rust 2024 edition (#2367)

* Update to rust 2024 edition

* Fixes

* Clean up imports

* Cargo fmt again

---------

Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
Dennis Kobert
2025-03-13 01:29:12 +01:00
committed by GitHub
parent 927d7dd9b2
commit beb1c6ae64
253 changed files with 980 additions and 1371 deletions

View File

@@ -1,18 +1,17 @@
use crate::document::value::TaggedValue;
use crate::proto::{ConstructionArgs, ProtoNetwork, ProtoNode, ProtoNodeInput};
use dyn_any::DynAny;
use graphene_core::memo::MemoHashGuard;
pub use graphene_core::uuid::generate_uuid;
pub use graphene_core::uuid::NodeId;
use graphene_core::{Cow, MemoHash, ProtoNodeIdentifier, Type};
pub mod value;
use crate::document::value::TaggedValue;
use crate::proto::{ConstructionArgs, ProtoNetwork, ProtoNode, ProtoNodeInput};
use dyn_any::DynAny;
use glam::IVec2;
use graphene_core::memo::MemoHashGuard;
pub use graphene_core::uuid::NodeId;
pub use graphene_core::uuid::generate_uuid;
use graphene_core::{Cow, MemoHash, ProtoNodeIdentifier, Type};
use log::Metadata;
use rustc_hash::FxHashMap;
use std::collections::hash_map::DefaultHasher;
use std::collections::HashMap;
use std::collections::hash_map::DefaultHasher;
use std::hash::{Hash, Hasher};
/// Hash two IDs together, returning a new ID that is always consistent for two input IDs in a specific order.
@@ -455,33 +454,17 @@ impl NodeInput {
}
pub fn as_value(&self) -> Option<&TaggedValue> {
if let NodeInput::Value { tagged_value, .. } = self {
Some(tagged_value)
} else {
None
}
if let NodeInput::Value { tagged_value, .. } = self { Some(tagged_value) } else { None }
}
pub fn as_value_mut(&mut self) -> Option<MemoHashGuard<TaggedValue>> {
if let NodeInput::Value { tagged_value, .. } = self {
Some(tagged_value.inner_mut())
} else {
None
}
if let NodeInput::Value { tagged_value, .. } = self { Some(tagged_value.inner_mut()) } else { None }
}
pub fn as_non_exposed_value(&self) -> Option<&TaggedValue> {
if let NodeInput::Value { tagged_value, exposed: false } = self {
Some(tagged_value)
} else {
None
}
if let NodeInput::Value { tagged_value, exposed: false } = self { Some(tagged_value) } else { None }
}
pub fn as_node(&self) -> Option<NodeId> {
if let NodeInput::Node { node_id, .. } = self {
Some(*node_id)
} else {
None
}
if let NodeInput::Node { node_id, .. } = self { Some(*node_id) } else { None }
}
}
@@ -942,12 +925,7 @@ impl NodeNetwork {
fn replace_node_inputs(&mut self, node_id: NodeId, old_input: (NodeId, usize), new_input: (NodeId, usize)) {
let Some(node) = self.nodes.get_mut(&node_id) else { return };
node.inputs.iter_mut().for_each(|input| {
if let NodeInput::Node {
node_id: ref mut input_id,
ref mut output_index,
..
} = input
{
if let NodeInput::Node { node_id: input_id, output_index, .. } = input {
if (*input_id, *output_index) == old_input {
(*input_id, *output_index) = new_input;
}
@@ -1241,12 +1219,7 @@ impl NodeNetwork {
}
}
for node_input in self.exports.iter_mut() {
if let NodeInput::Node {
ref mut node_id,
ref mut output_index,
..
} = node_input
{
if let NodeInput::Node { node_id, output_index, .. } = node_input {
if *node_id == id {
*node_id = input_node_id;
*output_index = node_input_output_index;
@@ -1382,9 +1355,7 @@ impl<'a> Iterator for RecursiveNodeIter<'a> {
mod test {
use super::*;
use crate::proto::{ConstructionArgs, ProtoNetwork, ProtoNode, ProtoNodeInput};
use graphene_core::ProtoNodeIdentifier;
use std::sync::atomic::AtomicU64;
fn gen_node_id() -> NodeId {
@@ -1478,7 +1449,7 @@ mod test {
assert_eq!(extraction_network.nodes.len(), 1);
let inputs = extraction_network.nodes.get(&NodeId(1)).unwrap().inputs.clone();
assert_eq!(inputs.len(), 1);
assert!(matches!(&inputs[0].as_value(), &Some(TaggedValue::DocumentNode(ref network), ..) if network == &id_node));
assert!(matches!(&inputs[0].as_value(), &Some(TaggedValue::DocumentNode(network), ..) if network == &id_node));
}
#[test]

View File

@@ -2,17 +2,15 @@ use super::DocumentNode;
pub use crate::imaginate_input::{ImaginateCache, ImaginateController, ImaginateMaskStartingFill, ImaginateSamplingMethod};
use crate::proto::{Any as DAny, FutureAny};
use crate::wasm_application_io::WasmEditorApi;
use dyn_any::DynAny;
pub use dyn_any::StaticType;
pub use glam::{DAffine2, DVec2, IVec2, UVec2};
use graphene_core::raster::brush_cache::BrushCache;
use graphene_core::raster::{BlendMode, LuminanceCalculation};
use graphene_core::renderer::RenderMetadata;
use graphene_core::uuid::NodeId;
use graphene_core::vector::style::Fill;
use graphene_core::{Color, MemoHash, Node, Type};
pub use glam::{DAffine2, DVec2, IVec2, UVec2};
use std::fmt::Display;
use std::hash::Hash;
use std::marker::PhantomData;

View File

@@ -1,7 +1,6 @@
use std::error::Error;
use crate::document::NodeNetwork;
use crate::proto::{LocalFuture, ProtoNetwork};
use std::error::Error;
pub struct Compiler {}

View File

@@ -1,6 +1,5 @@
use dyn_any::DynAny;
use graphene_core::Color;
use std::borrow::Cow;
use std::fmt::Debug;
use std::sync::atomic::{AtomicBool, Ordering};

View File

@@ -3,7 +3,7 @@ extern crate log;
#[macro_use]
extern crate graphene_core;
pub use graphene_core::{concrete, generic, ProtoNodeIdentifier, Type, TypeDescriptor};
pub use graphene_core::{ProtoNodeIdentifier, Type, TypeDescriptor, concrete, generic};
pub mod document;
pub mod proto;

View File

@@ -1,9 +1,7 @@
use crate::document::{value, InlineRust};
use crate::document::{InlineRust, value};
use crate::document::{NodeId, OriginalLocation};
pub use graphene_core::registry::*;
use graphene_core::*;
use rustc_hash::FxHashMap;
#[cfg(feature = "serde")]
use std::borrow::Cow;

View File

@@ -1,16 +1,12 @@
use dyn_any::StaticType;
use graphene_core::application_io::SurfaceHandleFrame;
use graphene_core::application_io::{ApplicationError, ApplicationIo, ResourceFuture, SurfaceHandle, SurfaceId};
use wgpu_executor::WgpuExecutor;
use dyn_any::StaticType;
#[cfg(target_arch = "wasm32")]
use js_sys::{Object, Reflect};
use std::collections::HashMap;
use std::sync::Arc;
#[cfg(target_arch = "wasm32")]
use std::sync::atomic::AtomicU64;
use std::sync::Arc;
// #[cfg(not(target_arch = "wasm32"))]
// use std::sync::Mutex;
#[cfg(feature = "tokio")]
use tokio::io::AsyncReadExt;
#[cfg(target_arch = "wasm32")]
@@ -18,9 +14,10 @@ use wasm_bindgen::JsCast;
#[cfg(target_arch = "wasm32")]
use wasm_bindgen::JsValue;
#[cfg(target_arch = "wasm32")]
use web_sys::window;
#[cfg(target_arch = "wasm32")]
use web_sys::HtmlCanvasElement;
#[cfg(target_arch = "wasm32")]
use web_sys::window;
use wgpu_executor::WgpuExecutor;
#[derive(Debug)]
struct WindowWrapper {