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

xuanwo pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-opendal.git


The following commit(s) were added to refs/heads/main by this push:
     new 8c229d1ca chore: Fix clippy warnings found in rust 1.75 (#3849)
8c229d1ca is described below

commit 8c229d1cad616eb95195fbfff510c44cbc1d45c5
Author: Xuanwo <[email protected]>
AuthorDate: Fri Dec 29 11:04:31 2023 +0800

    chore: Fix clippy warnings found in rust 1.75 (#3849)
    
    * Fix
    
    Signed-off-by: Xuanwo <[email protected]>
    
    * Fix build
    
    Signed-off-by: Xuanwo <[email protected]>
    
    * Fix
    
    Signed-off-by: Xuanwo <[email protected]>
    
    * Fix fmt
    
    Signed-off-by: Xuanwo <[email protected]>
    
    ---------
    
    Signed-off-by: Xuanwo <[email protected]>
---
 bindings/python/src/file.rs              |  3 +++
 core/src/services/huggingface/backend.rs |  2 +-
 core/src/services/mod.rs                 |  2 ++
 core/src/services/webdav/backend.rs      |  2 +-
 integrations/object_store/src/lib.rs     | 16 ++++++++--------
 5 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/bindings/python/src/file.rs b/bindings/python/src/file.rs
index 09cc6daeb..304bb0f31 100644
--- a/bindings/python/src/file.rs
+++ b/bindings/python/src/file.rs
@@ -15,6 +15,9 @@
 // specific language governing permissions and limitations
 // under the License.
 
+// Remove this allow after 
<https://github.com/rust-lang/rust-clippy/issues/12039> fixed.
+#![allow(clippy::unnecessary_fallible_conversions)]
+
 use std::io::Read;
 use std::io::Seek;
 use std::io::SeekFrom;
diff --git a/core/src/services/huggingface/backend.rs 
b/core/src/services/huggingface/backend.rs
index 0974395ea..70e6d39b5 100644
--- a/core/src/services/huggingface/backend.rs
+++ b/core/src/services/huggingface/backend.rs
@@ -309,7 +309,7 @@ impl Accessor for HuggingfaceBackend {
                     .map_err(new_json_deserialize_error)?;
 
                 // NOTE: if the file is not found, the server will return 200 
with an empty array
-                if let Some(status) = decoded_response.get(0) {
+                if let Some(status) = decoded_response.first() {
                     if let Some(commit_info) = status.last_commit.as_ref() {
                         meta.set_last_modified(parse_datetime_from_rfc3339(
                             commit_info.date.as_str(),
diff --git a/core/src/services/mod.rs b/core/src/services/mod.rs
index 910908001..e9e42675b 100644
--- a/core/src/services/mod.rs
+++ b/core/src/services/mod.rs
@@ -69,6 +69,8 @@ pub use ftp::FtpConfig;
 mod gcs;
 #[cfg(feature = "services-gcs")]
 pub use gcs::Gcs;
+#[cfg(feature = "services-gcs")]
+pub use gcs::GcsConfig;
 
 #[cfg(feature = "services-ghac")]
 mod ghac;
diff --git a/core/src/services/webdav/backend.rs 
b/core/src/services/webdav/backend.rs
index a7e461cb4..36a960940 100644
--- a/core/src/services/webdav/backend.rs
+++ b/core/src/services/webdav/backend.rs
@@ -350,7 +350,7 @@ impl Accessor for WebdavBackend {
             
quick_xml::de::from_reader(bs.reader()).map_err(new_xml_deserialize_error)?;
         let item = result
             .response
-            .get(0)
+            .first()
             .ok_or_else(|| {
                 Error::new(
                     ErrorKind::Unexpected,
diff --git a/integrations/object_store/src/lib.rs 
b/integrations/object_store/src/lib.rs
index 5d6123c1d..3ebc44e98 100644
--- a/integrations/object_store/src/lib.rs
+++ b/integrations/object_store/src/lib.rs
@@ -341,11 +341,11 @@ mod tests {
         let op = Operator::new(services::Memory::default()).unwrap().finish();
         let object_store = Arc::new(OpendalStore::new(op));
 
-        let path: Path = "data/test.txt".try_into().unwrap();
+        let path: Path = "data/test.txt".into();
         let bytes = Bytes::from_static(b"hello, world!");
         object_store.put(&path, bytes).await.unwrap();
 
-        let path: Path = "data/nested/test.txt".try_into().unwrap();
+        let path: Path = "data/nested/test.txt".into();
         let bytes = Bytes::from_static(b"hello, world! I am nested.");
         object_store.put(&path, bytes).await.unwrap();
 
@@ -358,7 +358,7 @@ mod tests {
         let object_store: Arc<dyn ObjectStore> = 
Arc::new(OpendalStore::new(op));
 
         // Retrieve a specific file
-        let path: Path = "data/test.txt".try_into().unwrap();
+        let path: Path = "data/test.txt".into();
 
         let bytes = Bytes::from_static(b"hello, world!");
         object_store.put(&path, bytes.clone()).await.unwrap();
@@ -382,7 +382,7 @@ mod tests {
     #[tokio::test]
     async fn test_list() {
         let object_store = create_test_object_store().await;
-        let path: Path = "data/".try_into().unwrap();
+        let path: Path = "data/".into();
         let results = object_store
             .list(Some(&path))
             .await
@@ -409,7 +409,7 @@ mod tests {
         assert_eq!(locations, expected_locations);
 
         for (location, bytes) in expected_files {
-            let path: Path = location.try_into().unwrap();
+            let path: Path = location.into();
             assert_eq!(
                 object_store
                     .get(&path)
@@ -426,7 +426,7 @@ mod tests {
     #[tokio::test]
     async fn test_list_with_delimiter() {
         let object_store = create_test_object_store().await;
-        let path: Path = "data/".try_into().unwrap();
+        let path: Path = "data/".into();
         let result = 
object_store.list_with_delimiter(Some(&path)).await.unwrap();
         assert_eq!(result.objects.len(), 1);
         assert_eq!(result.common_prefixes.len(), 1);
@@ -437,8 +437,8 @@ mod tests {
     #[tokio::test]
     async fn test_list_with_offset() {
         let object_store = create_test_object_store().await;
-        let path: Path = "data/".try_into().unwrap();
-        let offset: Path = "data/nested/test.txt".try_into().unwrap();
+        let path: Path = "data/".into();
+        let offset: Path = "data/nested/test.txt".into();
         let result = object_store
             .list_with_offset(Some(&path), &offset)
             .await

Reply via email to