aboutsummaryrefslogtreecommitdiff
path: root/mingling_core/src/asset
diff options
context:
space:
mode:
Diffstat (limited to 'mingling_core/src/asset')
-rw-r--r--mingling_core/src/asset/chain.rs2
-rw-r--r--mingling_core/src/asset/chain/error.rs10
-rw-r--r--mingling_core/src/asset/dispatcher.rs4
-rw-r--r--mingling_core/src/asset/enum_tag.rs2
-rw-r--r--mingling_core/src/asset/global_resource.rs19
-rw-r--r--mingling_core/src/asset/node.rs1
-rw-r--r--mingling_core/src/asset/renderer.rs2
7 files changed, 19 insertions, 21 deletions
diff --git a/mingling_core/src/asset/chain.rs b/mingling_core/src/asset/chain.rs
index 1b488fe..423e218 100644
--- a/mingling_core/src/asset/chain.rs
+++ b/mingling_core/src/asset/chain.rs
@@ -3,7 +3,7 @@ use crate::ChainProcess;
#[doc(hidden)]
pub mod error;
-/// Takes over a type (G: Previous) and converts it to another [AnyOutput](./struct.AnyOutput.html)
+/// Takes over a type (G: Previous) and converts it to another [`AnyOutput`](./struct.AnyOutput.html)
pub trait Chain<G> {
/// The previous type in the chain
type Previous;
diff --git a/mingling_core/src/asset/chain/error.rs b/mingling_core/src/asset/chain/error.rs
index ce69bc5..29abba1 100644
--- a/mingling_core/src/asset/chain/error.rs
+++ b/mingling_core/src/asset/chain/error.rs
@@ -13,8 +13,8 @@ pub enum ChainProcessError {
impl std::fmt::Display for ChainProcessError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
- ChainProcessError::Other(s) => write!(f, "Other error: {}", s),
- ChainProcessError::IO(e) => write!(f, "IO error: {}", e),
+ ChainProcessError::Other(s) => write!(f, "Other error: {s}"),
+ ChainProcessError::IO(e) => write!(f, "IO error: {e}"),
}
}
}
@@ -41,14 +41,14 @@ impl From<ProgramInternalExecuteError> for ChainProcessError {
ChainProcessError::Other("DispatcherNotFound".into())
}
ProgramInternalExecuteError::RendererNotFound(r) => {
- ChainProcessError::Other(format!("RendererNotFound: {}", r))
+ ChainProcessError::Other(format!("RendererNotFound: {r}"))
}
ProgramInternalExecuteError::Other(e) => ChainProcessError::Other(e),
ProgramInternalExecuteError::IO(e) => {
- ChainProcessError::Other(format!("IOError: {:?}", e))
+ ChainProcessError::Other(format!("IOError: {e:?}"))
}
ProgramInternalExecuteError::REPLPanic(program_panic) => {
- ChainProcessError::Other(format!("REPLPanic: {}", program_panic))
+ ChainProcessError::Other(format!("REPLPanic: {program_panic}"))
}
}
}
diff --git a/mingling_core/src/asset/dispatcher.rs b/mingling_core/src/asset/dispatcher.rs
index 95b3305..b62a0d0 100644
--- a/mingling_core/src/asset/dispatcher.rs
+++ b/mingling_core/src/asset/dispatcher.rs
@@ -2,7 +2,7 @@ use std::fmt::Display;
use crate::{ChainProcess, Program, ProgramCollect, asset::node::Node};
-/// Dispatches user input commands to specific [ChainProcess](./enum.ChainProcess.html)
+/// Dispatches user input commands to specific [`ChainProcess`](./enum.ChainProcess.html)
///
/// Note: If you are using [mingling_macros](https://crates.io/crates/mingling_macros),
/// you can use the `dispatcher!("node.subnode", CommandType => Entry)` macro to declare a `Dispatcher`
@@ -10,7 +10,7 @@ pub trait Dispatcher<C> {
/// Returns a command node for matching user input
fn node(&self) -> Node;
- /// Returns a [ChainProcess](./enum.ChainProcess.html) based on user input arguments,
+ /// Returns a [`ChainProcess`](./enum.ChainProcess.html) based on user input arguments,
/// to be sent to the specific invocation
fn begin(&self, args: Vec<String>) -> ChainProcess<C>;
diff --git a/mingling_core/src/asset/enum_tag.rs b/mingling_core/src/asset/enum_tag.rs
index 28428a6..d830e62 100644
--- a/mingling_core/src/asset/enum_tag.rs
+++ b/mingling_core/src/asset/enum_tag.rs
@@ -1,4 +1,4 @@
-/// Marker trait for EnumTag
+/// Marker trait for `EnumTag`
pub trait EnumTag {
/// Get the name and description of this enum
fn enum_info(&self) -> (&'static str, &'static str);
diff --git a/mingling_core/src/asset/global_resource.rs b/mingling_core/src/asset/global_resource.rs
index 98a8160..d03c6ea 100644
--- a/mingling_core/src/asset/global_resource.rs
+++ b/mingling_core/src/asset/global_resource.rs
@@ -25,11 +25,8 @@ where
Res: 'static + Default + ResourceMarker + Send + Sync,
Return: Default,
{
- let mut guard = match self.resources.lock() {
- Ok(guard) => guard,
- Err(_) => {
- return Return::default();
- }
+ let Ok(mut guard) = self.resources.lock() else {
+ return Return::default();
};
if let Some(arc_res) = guard
.get_mut(&TypeId::of::<Res>())
@@ -56,12 +53,9 @@ where
Res: 'static + Default + ResourceMarker + Send + Sync,
Return: Into<ChainProcess<C>>,
{
- let mut guard = match self.resources.lock() {
- Ok(guard) => guard,
- Err(_) => {
- let mut default_res = Res::res_default();
- return f(&mut default_res);
- }
+ let Ok(mut guard) = self.resources.lock() else {
+ let mut default_res = Res::res_default();
+ return f(&mut default_res);
};
if let Some(arc_res) = guard
.get_mut(&TypeId::of::<Res>())
@@ -81,6 +75,7 @@ where
}
/// Get an resources by type, returning `Res` if present
+ #[must_use]
pub fn res<Res: 'static + Send + Sync>(&self) -> Option<GlobalResource<Res>> {
let guard = self.resources.lock().ok()?;
let boxed_any = guard.get(&TypeId::of::<Res>())?;
@@ -100,6 +95,7 @@ where
}
/// Get a resource by type, returning `GlobalResource<Res>` or inserting a default
+ #[must_use]
pub fn res_or_default<Res: 'static + Send + Sync + ResourceMarker>(
&self,
) -> GlobalResource<Res> {
@@ -144,6 +140,7 @@ impl<ResType: 'static + Send + Sync> AsRef<ResType> for GlobalResource<ResType>
/// Resource marker trait, types that implement the Clone and Default traits can be considered as resources
pub trait ResourceMarker {
+ #[must_use]
fn res_clone(&self) -> Self;
fn res_default() -> Self;
fn modify<C>(f: impl FnOnce(&mut Self))
diff --git a/mingling_core/src/asset/node.rs b/mingling_core/src/asset/node.rs
index 035d227..4dfdb48 100644
--- a/mingling_core/src/asset/node.rs
+++ b/mingling_core/src/asset/node.rs
@@ -11,6 +11,7 @@ pub struct Node {
impl Node {
/// Append a new part to the node path.
+ #[must_use]
pub fn join(self, node: impl Into<String>) -> Node {
let mut new_node = self.node;
new_node.push(node.into());
diff --git a/mingling_core/src/asset/renderer.rs b/mingling_core/src/asset/renderer.rs
index de417a2..1d5a2c1 100644
--- a/mingling_core/src/asset/renderer.rs
+++ b/mingling_core/src/asset/renderer.rs
@@ -1,6 +1,6 @@
use crate::RenderResult;
-/// Takes over a type (Self::Previous) and converts it to a [`RenderResult`](./struct.RenderResult.html)
+/// Takes over a type (`Self::Previous`) and converts it to a [`RenderResult`](./struct.RenderResult.html)
pub trait Renderer {
/// The previous type in the chain
type Previous;