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

apitrou pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow.git


The following commit(s) were added to refs/heads/master by this push:
     new 7376aab  ARROW-2413: [Rust] Remove useless calls to format!().
7376aab is described below

commit 7376aab4043bc4e0499c6d866efe3074095c144a
Author: Bruce Mitchener <bruce.mitche...@gmail.com>
AuthorDate: Mon Apr 9 13:18:14 2018 +0200

    ARROW-2413: [Rust] Remove useless calls to format!().
    
    When there are no arguments to be formatted, we might as well
    just call `to_string` instead.  This fixes a number of warnings
    from clippy.
    
    Author: Bruce Mitchener <bruce.mitche...@gmail.com>
    
    Closes #1849 from waywardmonkeys/arrow-2413-remove-useless-calls-to-format 
and squashes the following commits:
    
    1043d32 <Bruce Mitchener> Remove useless calls to format!().
---
 rust/src/datatypes.rs | 66 ++++++++++++++++++++++++++-------------------------
 rust/src/memory.rs    |  6 ++---
 2 files changed, 37 insertions(+), 35 deletions(-)

diff --git a/rust/src/datatypes.rs b/rust/src/datatypes.rs
index ac2c2c6..a55ae0f 100644
--- a/rust/src/datatypes.rs
+++ b/rust/src/datatypes.rs
@@ -48,9 +48,9 @@ impl DataType {
                     Some(p) if p == "HALF" => Ok(DataType::Float16),
                     Some(p) if p == "SINGLE" => Ok(DataType::Float32),
                     Some(p) if p == "DOUBLE" => Ok(DataType::Float64),
-                    _ => Err(ArrowError::ParseError(format!(
-                        "floatingpoint precision missing or invalid"
-                    ))),
+                    _ => Err(ArrowError::ParseError(
+                        "floatingpoint precision missing or 
invalid".to_string(),
+                    )),
                 },
                 Some(s) if s == "int" => match map.get("isSigned") {
                     Some(&Value::Bool(true)) => match map.get("bitWidth") {
@@ -59,13 +59,13 @@ impl DataType {
                             Some(16) => Ok(DataType::Int16),
                             Some(32) => Ok(DataType::Int32),
                             Some(64) => Ok(DataType::Int32),
-                            _ => Err(ArrowError::ParseError(format!(
-                                "int bitWidth missing or invalid"
-                            ))),
+                            _ => Err(ArrowError::ParseError(
+                                "int bitWidth missing or invalid".to_string(),
+                            )),
                         },
-                        _ => Err(ArrowError::ParseError(format!(
-                            "int bitWidth missing or invalid"
-                        ))),
+                        _ => Err(ArrowError::ParseError(
+                            "int bitWidth missing or invalid".to_string(),
+                        )),
                     },
                     Some(&Value::Bool(false)) => match map.get("bitWidth") {
                         Some(&Value::Number(ref n)) => match n.as_u64() {
@@ -73,17 +73,17 @@ impl DataType {
                             Some(16) => Ok(DataType::UInt16),
                             Some(32) => Ok(DataType::UInt32),
                             Some(64) => Ok(DataType::UInt64),
-                            _ => Err(ArrowError::ParseError(format!(
-                                "int bitWidth missing or invalid"
-                            ))),
+                            _ => Err(ArrowError::ParseError(
+                                "int bitWidth missing or invalid".to_string(),
+                            )),
                         },
-                        _ => Err(ArrowError::ParseError(format!(
-                            "int bitWidth missing or invalid"
-                        ))),
+                        _ => Err(ArrowError::ParseError(
+                            "int bitWidth missing or invalid".to_string(),
+                        )),
                     },
-                    _ => Err(ArrowError::ParseError(format!(
-                        "int signed missing or invalid"
-                    ))),
+                    _ => Err(ArrowError::ParseError(
+                        "int signed missing or invalid".to_string(),
+                    )),
                 },
                 Some(other) => Err(ArrowError::ParseError(format!(
                     "invalid type name: {}",
@@ -97,10 +97,12 @@ impl DataType {
                             .collect::<Result<Vec<Field>, ArrowError>>();
                         Ok(DataType::Struct(fields?))
                     }
-                    _ => Err(ArrowError::ParseError(format!("empty type"))),
+                    _ => Err(ArrowError::ParseError("empty type".to_string())),
                 },
             },
-            _ => Err(ArrowError::ParseError(format!("invalid json value 
type"))),
+            _ => Err(ArrowError::ParseError(
+                "invalid json value type".to_string(),
+            )),
         }
     }
 
@@ -151,25 +153,25 @@ impl Field {
                 let name = match map.get("name") {
                     Some(&Value::String(ref name)) => name.to_string(),
                     _ => {
-                        return Err(ArrowError::ParseError(format!(
-                            "Field missing 'name' attribute"
-                        )))
+                        return Err(ArrowError::ParseError(
+                            "Field missing 'name' attribute".to_string(),
+                        ))
                     }
                 };
                 let nullable = match map.get("nullable") {
                     Some(&Value::Bool(b)) => b,
                     _ => {
-                        return Err(ArrowError::ParseError(format!(
-                            "Field missing 'nullable' attribute"
-                        )))
+                        return Err(ArrowError::ParseError(
+                            "Field missing 'nullable' attribute".to_string(),
+                        ))
                     }
                 };
                 let data_type = match map.get("type") {
                     Some(t) => DataType::from(t)?,
                     _ => {
-                        return Err(ArrowError::ParseError(format!(
-                            "Field missing 'type' attribute"
-                        )))
+                        return Err(ArrowError::ParseError(
+                            "Field missing 'type' attribute".to_string(),
+                        ))
                     }
                 };
                 Ok(Field {
@@ -178,9 +180,9 @@ impl Field {
                     data_type,
                 })
             }
-            _ => Err(ArrowError::ParseError(format!(
-                "Invalid json value type for field"
-            ))),
+            _ => Err(ArrowError::ParseError(
+                "Invalid json value type for field".to_string(),
+            )),
         }
     }
 
diff --git a/rust/src/memory.rs b/rust/src/memory.rs
index 41d4c53..e3bb786 100644
--- a/rust/src/memory.rs
+++ b/rust/src/memory.rs
@@ -28,9 +28,9 @@ pub fn allocate_aligned(size: i64) -> Result<*const u8, 
ArrowError> {
         let result = libc::posix_memalign(&mut page, ALIGNMENT, size as usize);
         match result {
             0 => Ok(mem::transmute::<*mut libc::c_void, *const u8>(page)),
-            _ => Err(ArrowError::MemoryError(format!(
-                "Failed to allocate memory"
-            ))),
+            _ => Err(ArrowError::MemoryError(
+                "Failed to allocate memory".to_string(),
+            )),
         }
     }
 }

-- 
To stop receiving notification emails like this one, please contact
apit...@apache.org.

Reply via email to