Skip to content

Commit df4b7ad

Browse files
committed
chore: fix
1 parent ab9d8b1 commit df4b7ad

File tree

9 files changed

+71
-165
lines changed

9 files changed

+71
-165
lines changed

rust/cubenativeutils/Cargo.lock

Lines changed: 44 additions & 139 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust/cubenativeutils/rustfmt.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
imports_granularity = "Crate"
1+
# TODO: Uncomment, when it will become stable in rustfmt - https://github.com/rust-lang/rustfmt/issues/4991
2+
# imports_granularity = "Crate"

rust/cubenativeutils/src/wrappers/neon/context.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ impl<'cx, C: Context<'cx> + NoenContextLifetimeExpand<'cx> + 'cx> NeonContextGua
5959
fn new(cx: C) -> Self {
6060
Self {
6161
context: ContextWrapper::new(cx.expand_lifetime()),
62-
lifetime: PhantomData::default(),
62+
lifetime: PhantomData,
6363
}
6464
}
6565

@@ -111,9 +111,9 @@ impl<C: Context<'static>> ContextHolder<C> {
111111
let res = cx.with_context(f);
112112
Ok(res)
113113
} else {
114-
Err(CubeError::internal(format!(
115-
"Call to neon context outside of its lifetime"
116-
)))
114+
Err(CubeError::internal(
115+
"Call to neon context outside of its lifetime".to_string(),
116+
))
117117
}
118118
}
119119
}

rust/cubenativeutils/src/wrappers/neon/object/base_types.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ impl<C: Context<'static>, T: 'static> NeonBox<C, T> {
8585
pub fn new(object: NeonTypeHandle<C, JsBox<T>>) -> Self {
8686
Self {
8787
object,
88-
_marker: PhantomData::default(),
88+
_marker: PhantomData,
8989
}
9090
}
9191
}

rust/cubenativeutils/src/wrappers/neon/object/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ impl<C: Context<'static> + 'static, V: Value + 'static> NeonTypeHandle<C, V> {
2929
}
3030

3131
pub fn get_object(&self) -> Handle<'static, V> {
32-
self.object.clone()
32+
self.object
3333
}
3434

3535
pub fn get_object_ref(&self) -> &Handle<'static, V> {
@@ -73,7 +73,7 @@ impl<C: Context<'static>, V: Value + 'static> Clone for NeonTypeHandle<C, V> {
7373
fn clone(&self) -> Self {
7474
Self {
7575
context: self.context.clone(),
76-
object: self.object.clone(),
76+
object: self.object,
7777
}
7878
}
7979
}
@@ -89,7 +89,7 @@ impl<C: Context<'static> + 'static> NeonObject<C> {
8989
}
9090

9191
pub fn get_object(&self) -> Handle<'static, JsValue> {
92-
self.object.clone()
92+
self.object
9393
}
9494

9595
pub fn get_object_ref(&self) -> &Handle<'static, JsValue> {
@@ -169,7 +169,7 @@ impl<C: Context<'static>> Clone for NeonObject<C> {
169169
fn clone(&self) -> Self {
170170
Self {
171171
context: self.context.clone(),
172-
object: self.object.clone(),
172+
object: self.object,
173173
}
174174
}
175175
}

rust/cubenativeutils/src/wrappers/neon/object/neon_function.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ impl<C: Context<'static> + 'static> NativeFunction<NeonInnerTypes<C>> for NeonFu
3939
let null = cx.null();
4040
neon_object
4141
.call(cx, null, neon_args)
42-
.map_err(|_| CubeError::internal(format!("Failed to call function ")))
42+
.map_err(|_| CubeError::internal("Failed to call function ".to_string()))
4343
})??;
4444
Ok(NativeObjectHandle::new(NeonObject::new(
4545
self.object.context.clone(),
@@ -54,7 +54,7 @@ impl<C: Context<'static> + 'static> NativeFunction<NeonInnerTypes<C>> for NeonFu
5454
let res = neon_object
5555
.to_string(cx)
5656
.map_err(|_| {
57-
CubeError::internal(format!("Can't convert function to string"))
57+
CubeError::internal("Can't convert function to string".to_string())
5858
})?
5959
.value(cx);
6060
Ok(res)

rust/cubenativeutils/src/wrappers/neon/object/neon_struct.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,13 @@ impl<C: Context<'static> + 'static> NativeStruct<NeonInnerTypes<C>> for NeonStru
7474
&self,
7575
) -> Result<Vec<NativeObjectHandle<NeonInnerTypes<C>>>, CubeError> {
7676
let neon_array = self.object.map_neon_object(|cx, neon_object| {
77-
let neon_array = neon_object
78-
.get_own_property_names(cx)
79-
.map_err(|_| CubeError::internal(format!("Cannot get own properties not found")))?;
77+
let neon_array = neon_object.get_own_property_names(cx).map_err(|_| {
78+
CubeError::internal("Cannot get own properties not found".to_string())
79+
})?;
8080

8181
neon_array
8282
.to_vec(cx)
83-
.map_err(|_| CubeError::internal(format!("Failed to convert array")))
83+
.map_err(|_| CubeError::internal("Failed to convert array".to_string()))
8484
})??;
8585
Ok(neon_array
8686
.into_iter()
@@ -102,7 +102,7 @@ impl<C: Context<'static> + 'static> NativeStruct<NeonInnerTypes<C>> for NeonStru
102102
.get::<JsFunction, _, _>(cx, method)
103103
.map_err(|_| CubeError::internal(format!("Method `{}` not found", method)))?;
104104
neon_method
105-
.call(cx, neon_object.clone(), neon_args)
105+
.call(cx, *neon_object, neon_args)
106106
.map_err(|err| {
107107
CubeError::internal(format!(
108108
"Failed to call method `{} {} {:?}",

rust/cubenativeutils/src/wrappers/serializer/deserializer.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ impl<'de, IT: InnerTypes> Deserializer<'de> for NativeSerdeDeserializer<IT> {
123123
V: Visitor<'de>,
124124
{
125125
if let Ok(val) = self.input.to_number() {
126-
visitor.visit_f64(val.value().unwrap() as f64)
126+
visitor.visit_f64(val.value().unwrap())
127127
} else {
128128
Err(NativeObjSerializerError::Message(
129129
"JS Number expected for f64 field".to_string(),
@@ -178,7 +178,7 @@ struct NativeMapDeserializer<IT: InnerTypes> {
178178
impl<IT: InnerTypes> NativeMapDeserializer<IT> {
179179
pub fn new(input: IT::Struct) -> Result<Self, NativeObjSerializerError> {
180180
let prop_names = input.get_own_property_names().map_err(|_| {
181-
NativeObjSerializerError::Message(format!("Failed to get property names"))
181+
NativeObjSerializerError::Message("Failed to get property names".to_string())
182182
})?;
183183
let len = prop_names.len() as u32;
184184
Ok(Self {
@@ -214,23 +214,23 @@ impl<'de, IT: InnerTypes> MapAccess<'de> for NativeMapDeserializer<IT> {
214214
V: DeserializeSeed<'de>,
215215
{
216216
if self.value_idx >= self.len {
217-
return Err(NativeObjSerializerError::Message(format!(
218-
"Array index out of bounds"
219-
)));
217+
return Err(NativeObjSerializerError::Message(
218+
"Array index out of bounds".to_string(),
219+
));
220220
}
221221
let prop_name = self
222222
.prop_names
223223
.get(self.value_idx as usize)
224224
.ok_or_else(|| {
225-
NativeObjSerializerError::Message(format!("Array index out of bounds"))
225+
NativeObjSerializerError::Message("Array index out of bounds".to_string())
226226
})?;
227227
let prop_string = prop_name
228228
.to_string()
229229
.and_then(|s| s.value())
230-
.map_err(|_| NativeObjSerializerError::Message(format!("key should be string")))?;
230+
.map_err(|_| NativeObjSerializerError::Message("key should be string".to_string()))?;
231231

232232
let value = self.input.get_field(&prop_string).map_err(|_| {
233-
NativeObjSerializerError::Message(format!("Failed to get property name"))
233+
NativeObjSerializerError::Message("Failed to get property name".to_string())
234234
})?;
235235

236236
self.value_idx += 1;

rust/cubenativeutils/src/wrappers/serializer/serializer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ impl<IT: InnerTypes> ser::Serializer for NativeSerdeSerializer<IT> {
115115

116116
fn serialize_f64(self, v: f64) -> Result<Self::Ok, Self::Error> {
117117
Ok(NativeObjectHandle::new(
118-
self.context.number(v as f64)?.into_object(),
118+
self.context.number(v)?.into_object(),
119119
))
120120
}
121121

0 commit comments

Comments
 (0)