From c5736152b0adeef17349265c4b9277ba17b8bcfd Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Sat, 11 Jul 2026 14:44:17 +0800 Subject: feat: require renderers to return RenderResult instead of mutating one BREAKING CHANGE: The `render` method on `Renderer`, `HelpRequest`, and `ProgramCollect` now returns `RenderResult` instead of taking `&mut RenderResult`. The `r_print!` and `r_println!` macros have been removed in favor of using `std::io::Write` directly on `RenderResult`. --- mling/src/proj_mgr/show_binaries.rs | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'mling/src/proj_mgr/show_binaries.rs') diff --git a/mling/src/proj_mgr/show_binaries.rs b/mling/src/proj_mgr/show_binaries.rs index d6872cf..fd2f406 100644 --- a/mling/src/proj_mgr/show_binaries.rs +++ b/mling/src/proj_mgr/show_binaries.rs @@ -2,18 +2,19 @@ use std::path::PathBuf; use colored::Colorize; use mingling::{ - Groupped, - macros::{chain, pack, r_print, r_println, renderer}, + macros::{chain, pack, renderer}, + Groupped, RenderResult, }; use serde::Serialize; +use std::io::Write as _; use crate::{ - Next, proj_mgr::{ + metadata::{read_metadata, CargoLockFile}, EntryShowBinaries, - metadata::{CargoLockFile, read_metadata}, }, res::ResManifestPath, + Next, }; #[derive(Serialize, Groupped)] @@ -58,16 +59,20 @@ pub fn handle_show_binaries(_args: EntryShowBinaries, manifest_path: &ResManifes } #[renderer] -pub fn render_binaries(binaries: ResultBinaries) -> String { - r_println!("{}", "Binaries:".bright_cyan().bold()); +pub fn render_binaries(binaries: ResultBinaries) -> RenderResult { + let mut result = RenderResult::default(); + writeln!(result, "{}", "Binaries:".bright_cyan().bold()).ok(); if let Some(max_name_len) = binaries.binaries.iter().map(|b| b.name.len()).max() { for binary in &binaries.binaries { - r_println!( + writeln!( + result, " {:width$} `{}`", binary.name.bright_yellow().bold(), binary.path.display().to_string().italic(), width = max_name_len - ); + ) + .ok(); } } + result } -- cgit