diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-06-06 15:36:28 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-06-06 15:36:28 +0900 |
| commit | 44e82cc7d937d49593c6f436d03a38f3371b6873 (patch) | |
| tree | 227a7aac9d6b39c92108ffb78c0945cb7737d27c /crates/shirabe/src/package/link.rs | |
| parent | 165b77b169fbb13a984b6d80f610e3aaa33334e6 (diff) | |
| download | php-shirabe-44e82cc7d937d49593c6f436d03a38f3371b6873.tar.gz php-shirabe-44e82cc7d937d49593c6f436d03a38f3371b6873.tar.zst php-shirabe-44e82cc7d937d49593c6f436d03a38f3371b6873.zip | |
refactor(operation,link): port __toString to Display
Move __toString ports to std::fmt::Display: convert Link's inherent
to_string() and make OperationInterface require Display instead of a
to_string() method, with each operation implementing Display.
Also fix the operation __toString output to use show(false), matching
SolverOperation::__toString() (was show(true)).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src/package/link.rs')
| -rw-r--r-- | crates/shirabe/src/package/link.rs | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/crates/shirabe/src/package/link.rs b/crates/shirabe/src/package/link.rs index 946c664..0157989 100644 --- a/crates/shirabe/src/package/link.rs +++ b/crates/shirabe/src/package/link.rs @@ -76,23 +76,26 @@ impl Link { &self.pretty_constraint } - pub fn to_string(&self) -> String { + pub fn get_pretty_string(&self, source_package: PackageInterfaceHandle) -> String { format!( - "{} {} {} ({})", - self.source, + "{} {} {} {}", + source_package.get_pretty_string(), self.description, self.target, - self.constraint.to_string(), + self.constraint.get_pretty_string() ) } +} - pub fn get_pretty_string(&self, source_package: PackageInterfaceHandle) -> String { - format!( - "{} {} {} {}", - source_package.get_pretty_string(), +impl std::fmt::Display for Link { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!( + f, + "{} {} {} ({})", + self.source, self.description, self.target, - self.constraint.get_pretty_string() + self.constraint.to_string(), ) } } |
