aboutsummaryrefslogtreecommitdiff
path: root/mingling/src
diff options
context:
space:
mode:
Diffstat (limited to 'mingling/src')
-rw-r--r--mingling/src/example_docs.rs13
-rw-r--r--mingling/src/res.rs3
-rw-r--r--mingling/src/res/exit_code.rs6
-rw-r--r--mingling/src/setups/exit_code.rs6
4 files changed, 16 insertions, 12 deletions
diff --git a/mingling/src/example_docs.rs b/mingling/src/example_docs.rs
index 903abf8..3755553 100644
--- a/mingling/src/example_docs.rs
+++ b/mingling/src/example_docs.rs
@@ -1088,7 +1088,7 @@ pub mod example_error_handling {}
///
/// Source code (./src/main.rs)
/// ```ignore
-/// use mingling::{prelude::*, res::ExitCode, setup::ExitCodeSetup};
+/// use mingling::{prelude::*, res::ResExitCode, setup::ExitCodeSetup};
///
/// fn main() {
/// let mut program = ThisProgram::new();
@@ -1124,11 +1124,11 @@ pub mod example_error_handling {}
/// r_println!("Hello, {}", *name);
/// }
///
-/// // Define renderer, render error message _____________ Inject exit code resource
+/// // Define renderer, render error message _______________ Inject exit code resource
/// // /
/// /// Renders the error when no name is provided |
-/// #[renderer] // vvvvvvvvvvvvv
-/// fn render_error_no_name_provided(_: ErrorNoNameProvided, ec: &mut ExitCode) {
+/// #[renderer] // vvvvvvvvvvvvvvvv
+/// fn render_error_no_name_provided(_: ErrorNoNameProvided, ec: &mut ResExitCode) {
/// ec.exit_code = 1;
///
/// // Prompt when no name is provided
@@ -1521,8 +1521,9 @@ pub mod example_panic_unwind {}
/// use mingling::{
/// hook::ProgramHook,
/// prelude::*,
+/// res::ResREPL,
/// setup::{BasicREPLOutputSetup, BasicREPLPromptSetup, BasicREPLReadlineSetup},
-/// this, REPL,
+/// this,
/// };
/// use std::{env::current_dir, path::PathBuf};
///
@@ -1656,7 +1657,7 @@ pub mod example_panic_unwind {}
/// #[chain]
/// fn handle_exit(
/// _prev: EntryExit,
-/// repl: &mut REPL, // Import REPL resource, registered in `exec_repl`, usable directly
+/// repl: &mut ResREPL, // Import REPL resource, registered in `exec_repl`, usable directly
/// ) {
/// // Set the REPL exit flag; REPL will exit after this loop iteration
/// repl.exit = true;
diff --git a/mingling/src/res.rs b/mingling/src/res.rs
index d625f8f..982fe91 100644
--- a/mingling/src/res.rs
+++ b/mingling/src/res.rs
@@ -1,2 +1,5 @@
mod exit_code;
pub use exit_code::*;
+
+#[allow(unused_imports)]
+pub use mingling_core::core_res::*;
diff --git a/mingling/src/res/exit_code.rs b/mingling/src/res/exit_code.rs
index e90d067..93ce98b 100644
--- a/mingling/src/res/exit_code.rs
+++ b/mingling/src/res/exit_code.rs
@@ -9,7 +9,7 @@ use mingling_core::{ProgramCollect, this};
/// The exit code is stored globally per `ProgramCollect` type and can be
/// retrieved via [`exit_code()`] or updated via [`update_exit_code()`].
#[derive(Debug, Default, Clone, Copy)]
-pub struct ExitCode {
+pub struct ResExitCode {
/// The numeric exit code value.
pub exit_code: i32,
}
@@ -19,7 +19,7 @@ pub fn update_exit_code<C>(exit_code: i32)
where
C: ProgramCollect<Enum = C> + 'static,
{
- this::<C>().modify_res(|e: &mut ExitCode| e.exit_code = exit_code);
+ this::<C>().modify_res(|e: &mut ResExitCode| e.exit_code = exit_code);
}
/// Retrieves the globally stored exit code for the given `ProgramCollect` type.
@@ -29,7 +29,7 @@ pub fn exit_code<C>() -> i32
where
C: ProgramCollect<Enum = C> + 'static,
{
- match this::<C>().res::<ExitCode>() {
+ match this::<C>().res::<ResExitCode>() {
Some(e) => e.exit_code,
None => 0,
}
diff --git a/mingling/src/setups/exit_code.rs b/mingling/src/setups/exit_code.rs
index 88742d5..ed8204c 100644
--- a/mingling/src/setups/exit_code.rs
+++ b/mingling/src/setups/exit_code.rs
@@ -2,7 +2,7 @@ use std::marker::PhantomData;
use mingling_core::{ProgramCollect, hook::ProgramHook, setup::ProgramSetup, this};
-use crate::res::ExitCode;
+use crate::res::ResExitCode;
/// Provides the ability to control the program's exit code, which is returned when the program ends.
///
@@ -29,11 +29,11 @@ where
{
fn setup(self, program: &mut crate::Program<C>) {
// Insert resource
- program.with_resource(ExitCode { exit_code: 0 });
+ program.with_resource(ResExitCode { exit_code: 0 });
// Insert hook to override exit code before program ends
program.with_hook(ProgramHook::empty().on_finish(|| {
- let this = this::<C>().res_or_default::<ExitCode>();
+ let this = this::<C>().res_or_default::<ResExitCode>();
this.exit_code
}));
}