hir::Ty had two impl blocks; combine them into one.

parent d0fa4c9c
......@@ -132,39 +132,6 @@ pub enum Ty<'ast> {
Owned(&'ast syn::Path),
}
impl<'ast> Ty<'ast> {
pub fn to_gtype_string(&self) -> &'static str {
match *self {
Ty::Unit => "gobject_sys::G_TYPE_NONE",
Ty::Char(_) => "gobject_sys::G_TYPE_UINT", // <char as ToGlib>::GlibType = u32
Ty::Bool(_) => "gobject_sys::G_TYPE_BOOLEAN",
Ty::Borrowed(_) => unimplemented!(),
Ty::Integer(ref ident) => match ident.to_owned_string().as_str() {
"i8" => "gobject_sys::G_TYPE_CHAR",
"i16" => unimplemented!("should we promote i16 to i32?"),
"i32" => "gobject_sys::G_TYPE_INT",
"i64" => "gobject_sys::G_TYPE_INT64",
"isize" => unimplemented!(),
"u8" => "gobject_sys::G_TYPE_UCHAR",
"u16" => unimplemented!("should we promote u16 to u32?"),
"u32" => "gobject_sys::G_TYPE_UINT",
"u64" => "gobject_sys::G_TYPE_UINT64",
"usize" => unimplemented!(),
_ => unreachable!(),
},
Ty::Owned(_) => unimplemented!(),
}
}
pub fn to_gtype_path(&self) -> Path {
path_from_string(self.to_gtype_string())
}
}
fn path_from_string(s: &str) -> Path {
parse_str::<Path>(s).unwrap()
}
......@@ -511,6 +478,37 @@ impl<'ast> Ty<'ast> {
_other => Ok(Ty::Owned(t)),
}
}
pub fn to_gtype_string(&self) -> &'static str {
match *self {
Ty::Unit => "gobject_sys::G_TYPE_NONE",
Ty::Char(_) => "gobject_sys::G_TYPE_UINT", // <char as ToGlib>::GlibType = u32
Ty::Bool(_) => "gobject_sys::G_TYPE_BOOLEAN",
Ty::Borrowed(_) => unimplemented!(),
Ty::Integer(ref ident) => match ident.to_owned_string().as_str() {
"i8" => "gobject_sys::G_TYPE_CHAR",
"i16" => unimplemented!("should we promote i16 to i32?"),
"i32" => "gobject_sys::G_TYPE_INT",
"i64" => "gobject_sys::G_TYPE_INT64",
"isize" => unimplemented!(),
"u8" => "gobject_sys::G_TYPE_UCHAR",
"u16" => unimplemented!("should we promote u16 to u32?"),
"u32" => "gobject_sys::G_TYPE_UINT",
"u64" => "gobject_sys::G_TYPE_UINT64",
"usize" => unimplemented!(),
_ => unreachable!(),
},
Ty::Owned(_) => unimplemented!(),
}
}
pub fn to_gtype_path(&self) -> Path {
path_from_string(self.to_gtype_string())
}
}
impl<'ast> Property<'ast> {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment