Making ArrayBufferView & BufferSource a union

This commit is contained in:
Benjamin Kampmann
2018-08-30 12:15:37 +02:00
parent 031ba39036
commit 8b08fc16c5
2 changed files with 28 additions and 9 deletions

View File

@ -291,12 +291,28 @@ impl<'src> FirstPassRecord<'src> {
// Slice types aren't supported because they don't implement
// `Into<JsValue>`
if let syn::Type::Reference(ty) = &ty {
match &*ty.elem {
syn::Type::Slice(_) => return None,
_ => {}
}
}
match ty {
syn::Type::Reference(ref i) =>
match &*i.elem {
syn::Type::Slice(_) => return None,
_ => ()
}
syn::Type::Path(ref path, ..) =>
// check that our inner don't contains slices either
for seg in path.path.segments.iter() {
if let syn::PathArguments::AngleBracketed(ref arg) = seg.arguments {
for elem in &arg.args {
if let syn::GenericArgument::Type(syn::Type::Reference(ref i)) = elem {
match &*i.elem {
syn::Type::Slice(_) => return None,
_ => ()
}
}
}
}
}
_ => ()
};
// Similarly i64/u64 aren't supported because they don't
// implement `Into<JsValue>`