[pbs-devel] [PATCH proxmox 02/12] auth-api: implement `Display` for `Realm{, Ref}`

Wolfgang Bumiller w.bumiller at proxmox.com
Fri Aug 11 12:32:14 CEST 2023


On Tue, Aug 08, 2023 at 02:22:04PM +0200, Christoph Heiss wrote:
> Signed-off-by: Christoph Heiss <c.heiss at proxmox.com>
> ---
>  proxmox-auth-api/src/types.rs | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 
> diff --git a/proxmox-auth-api/src/types.rs b/proxmox-auth-api/src/types.rs
> index 319ac4b..8c6d7eb 100644
> --- a/proxmox-auth-api/src/types.rs
> +++ b/proxmox-auth-api/src/types.rs
> @@ -327,6 +327,18 @@ impl PartialEq<Realm> for &RealmRef {
>      }
>  }
> 
> +impl fmt::Display for Realm {
> +    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
> +        write!(f, "{}", self.0)

`self.0` is a String, we don't need to involve the whole formatting
machinery, just use `f.write_str(&self.0)`.
Btw. for a mere "forwarding" an inner value to its `Display` trait one
can also skip the formatting machinery and use
`fmt::Display::fmt(&self.0, f)` directly.

> +    }
> +}
> +
> +impl fmt::Display for RealmRef {
> +    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
> +        write!(f, "{}", &self.0)

same

> +    }
> +}
> +
>  #[api(
>      type: String,
>      format: &PROXMOX_TOKEN_NAME_FORMAT,
> --
> 2.41.0





More information about the pbs-devel mailing list