This is an automated email from the ASF dual-hosted git repository.

tqchen pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tvm-ffi.git


The following commit(s) were added to refs/heads/main by this push:
     new f3096d8d [Rust] Display honors width and alignment (#955)
f3096d8d is described below

commit f3096d8db5341b1af3786e360ef07d06f8631966
Author: Tianqi Chen <[email protected]>
AuthorDate: Fri Nov 6 22:31:39 2026 -0500

    [Rust] Display honors width and alignment (#955)
    
    `Display` for `Any`, `AnyView`, containers and derived object refs now
    writes through `Formatter::pad`, so width, fill, alignment and precision
    apply as they do for `str` (for example `format!("{:>10}", any)`).
    Previously the printed text was written directly and those format
    options were ignored.
---
 rust/tvm-ffi/src/any.rs | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/rust/tvm-ffi/src/any.rs b/rust/tvm-ffi/src/any.rs
index ac30bea5..f7c5d203 100644
--- a/rust/tvm-ffi/src/any.rs
+++ b/rust/tvm-ffi/src/any.rs
@@ -412,9 +412,9 @@ impl std::fmt::Display for AnyView<'_> {
             .call_packed(&[*self])
             .and_then(crate::String::try_from);
         match repr {
-            Ok(text) => f.write_str(text.as_str()),
+            Ok(text) => f.pad(text.as_str()),
             // Formatting cannot fail, so a printer error falls back to the 
type key.
-            Err(_) => 
f.write_str(&object::type_key_of_index(self.type_index())),
+            Err(_) => f.pad(&object::type_key_of_index(self.type_index())),
         }
     }
 }

Reply via email to