You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opendal.apache.org by "Xuanwo (via GitHub)" <gi...@apache.org> on 2025/04/05 13:14:11 UTC

Re: [PR] chore(core/types): rename `with_user_metadata` to `set_user_metadata` [opendal]

Xuanwo commented on code in PR #5960:
URL: https://github.com/apache/opendal/pull/5960#discussion_r2029869379


##########
core/src/types/metadata.rs:
##########
@@ -429,7 +429,7 @@ impl Metadata {
     }
 
     /// Set user defined metadata of this entry
-    pub fn with_user_metadata(&mut self, data: HashMap<String, String>) -> &mut Self {
+    pub fn set_user_metadata(&mut self, data: HashMap<String, String>) -> &mut Self {

Review Comment:
   The difference between `with_xxx` and `set_xxx` is:
   
   - `with_xxx` accepts an owned type, requiring no `Copy` or `Clone`, but it consumes `self`.
   - `set_xxx` accepts a borrowed type, which may require an additional clone, but only needs `&mut self`.
   
   The current API sits somewhere in between these two approaches. It might be better to change it to `with_user_metadata(mut self, data)` instead.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@opendal.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org