Format PR 361 with rustfmt
diff --git a/gen/src/write.rs b/gen/src/write.rs
index 9b4e120..3184604 100644
--- a/gen/src/write.rs
+++ b/gen/src/write.rs
@@ -1245,12 +1245,13 @@
let instance = to_mangled(&out.namespace, ty);
let can_construct_from_value = match ty {
- // Some aliases are to opaque types; some are to trivial types.
- // We can't know at code generation time, so we generate both C++
- // and Rust side bindings for a "new" method anyway. But the Rust
- // code can't be called for Opaque types because the 'new'
- // method is not implemented.
- Type::Ident(ident) => types.structs.contains_key(ident) || types.aliases.contains_key(ident),
+ // Some aliases are to opaque types; some are to trivial types. We can't
+ // know at code generation time, so we generate both C++ and Rust side
+ // bindings for a "new" method anyway. But the Rust code can't be called
+ // for Opaque types because the 'new' method is not implemented.
+ Type::Ident(ident) => {
+ types.structs.contains_key(ident) || types.aliases.contains_key(ident)
+ }
_ => false,
};
diff --git a/src/unique_ptr.rs b/src/unique_ptr.rs
index 4bb5d67..3a5fc66 100644
--- a/src/unique_ptr.rs
+++ b/src/unique_ptr.rs
@@ -1,7 +1,7 @@
use crate::cxx_string::CxxString;
use crate::cxx_vector::{self, CxxVector, VectorElement};
-use crate::ExternType;
use crate::kind::Trivial;
+use crate::ExternType;
use core::ffi::c_void;
use core::fmt::{self, Debug, Display};
use core::marker::PhantomData;
@@ -36,7 +36,8 @@
/// Allocates memory on the heap and makes a UniquePtr pointing to it.
pub fn new(value: T) -> Self
where
- T: ExternType<Kind = Trivial> {
+ T: ExternType<Kind = Trivial>,
+ {
UniquePtr {
repr: T::__new(value),
ty: PhantomData,
diff --git a/tests/ui/unique_ptr_to_opaque.rs b/tests/ui/unique_ptr_to_opaque.rs
index 6f3bf8c..5ae03f8 100644
--- a/tests/ui/unique_ptr_to_opaque.rs
+++ b/tests/ui/unique_ptr_to_opaque.rs
@@ -9,7 +9,6 @@
}
}
-
#[cxx::bridge]
mod ffi {
impl UniquePtr<C> {}
@@ -22,5 +21,5 @@
}
fn main() {
- cxx::UniquePtr::new(outside::C { a: 4 } );
+ cxx::UniquePtr::new(outside::C { a: 4 });
}
diff --git a/tests/ui/unique_ptr_to_opaque.stderr b/tests/ui/unique_ptr_to_opaque.stderr
index 5525a05..f0e4aa0 100644
--- a/tests/ui/unique_ptr_to_opaque.stderr
+++ b/tests/ui/unique_ptr_to_opaque.stderr
@@ -1,7 +1,7 @@
error[E0271]: type mismatch resolving `<outside::C as ExternType>::Kind == Trivial`
- --> $DIR/unique_ptr_to_opaque.rs:25:5
+ --> $DIR/unique_ptr_to_opaque.rs:24:5
|
-25 | cxx::UniquePtr::new(outside::C { a: 4 } );
+24 | cxx::UniquePtr::new(outside::C { a: 4 });
| ^^^^^^^^^^^^^^^^^^^ expected enum `Trivial`, found enum `cxx::kind::Opaque`
|
= note: required by `UniquePtr::<T>::new`