From 18acfba07497ff5554f2790a170d003ed6a7dbfb Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Tue, 28 Jul 2026 22:40:33 +0800 Subject: feat(renderer): add exit_process method to RenderResult --- mingling_core/src/renderer/render_result.rs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/mingling_core/src/renderer/render_result.rs b/mingling_core/src/renderer/render_result.rs index d5b91ef..fc3f2b1 100644 --- a/mingling_core/src/renderer/render_result.rs +++ b/mingling_core/src/renderer/render_result.rs @@ -1,7 +1,7 @@ use std::{ fmt::{Display, Formatter}, io::Write, - process::ExitCode, + process::{ExitCode, exit}, }; use crate::RenderResultMode::{Stderr, Stdout}; @@ -496,6 +496,24 @@ impl RenderResult { exit_code: self.exit_code, } } + + /// Exits the process with the exit code stored in this `RenderResult`. + /// + /// This method calls `std::process::exit()` with the `exit_code` value, + /// terminating the current process immediately. + /// + /// # Examples + /// + /// ``` + /// use mingling_core::RenderResult; + /// + /// let mut result = RenderResult::new(); + /// result.exit_code = 42; + /// // result.exit_process(); // would exit with code 42 + /// ``` + pub fn exit_process(&self) { + exit(self.exit_code) + } } #[inline(always)] -- cgit