[pdm-devel] [PATCH proxmox 1/3] section-config: make write_section_config parameter more generic

Gabriel Goller g.goller at proxmox.com
Wed Apr 23 11:35:13 CEST 2025


On 15.04.2025 08:44, Wolfgang Bumiller wrote:
>style nit
>
>On Mon, Apr 14, 2025 at 02:00:43PM +0200, Gabriel Goller wrote:
>> The underlying function which gets called by `write_section_config` also
>> takes a `impl AsRef<Path>` and in some cases we do pass a path, so
>> taking the same parameter is better.
>>
>> Signed-off-by: Gabriel Goller <g.goller at proxmox.com>
>> ---
>>  proxmox-section-config/src/typed.rs | 3 ++-
>>  1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/proxmox-section-config/src/typed.rs b/proxmox-section-config/src/typed.rs
>> index 31e8e4b2e546..a25798e8a29b 100644
>> --- a/proxmox-section-config/src/typed.rs
>> +++ b/proxmox-section-config/src/typed.rs
>> @@ -1,6 +1,7 @@
>>  //! Support for `enum` typed section configs.
>>
>>  use std::collections::HashMap;
>> +use std::path::Path;
>>
>>  use anyhow::Error;
>>  use serde::{de::DeserializeOwned, Serialize};
>> @@ -90,7 +91,7 @@ pub trait ApiSectionDataEntry: Sized {
>>      }
>>
>>      /// Provided. Shortcut for `Self::section_config().write(filename, &data.try_into()?)`.
>> -    fn write_section_config(filename: &str, data: &SectionConfigData<Self>) -> Result<String, Error>
>> +    fn write_section_config(filename: impl AsRef<Path>, data: &SectionConfigData<Self>) -> Result<String, Error>
>
>- This is now too long (missing `fmt` call?)
>- I'd like to avoid too many `impl` parameters as they very quickly lead
>  to very long lines, particularly...
>
>>      where
>
>...since we already have a `where` section here. With `filename: P` the
>signature still fits in into a single line with
>    P: AsRef<Path>,
>here

Oops, forgot to run cargo fmt :)
Fixed it.




More information about the pdm-devel mailing list