Skip to content

Commit 8b90685

Browse files
committed
Move the type traits from values to types.
1 parent 47980d9 commit 8b90685

File tree

2 files changed

+22
-22
lines changed

2 files changed

+22
-22
lines changed

src/types/traits.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,3 +149,25 @@ impl PointerMathType for VectorType {
149149
type ValueType = VectorValue;
150150
type PtrConvType = VectorType;
151151
}
152+
153+
macro_rules! impl_try_from_basic_type_enum {
154+
($type_name:ident) => (
155+
impl TryFrom<BasicTypeEnum> for $type_name {
156+
type Error = &'static str;
157+
158+
fn try_from(ty: BasicTypeEnum) -> Result<Self, Self::Error> {
159+
match ty {
160+
BasicTypeEnum::$type_name(ty) => Ok(ty),
161+
_ => Err("bad try from"),
162+
}
163+
}
164+
}
165+
)
166+
}
167+
168+
impl_try_from_basic_type_enum!(ArrayType);
169+
impl_try_from_basic_type_enum!(FloatType);
170+
impl_try_from_basic_type_enum!(IntType);
171+
impl_try_from_basic_type_enum!(PointerType);
172+
impl_try_from_basic_type_enum!(StructType);
173+
impl_try_from_basic_type_enum!(VectorType);

src/values/traits.rs

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -147,25 +147,3 @@ impl_try_from_basic_value_enum!(FloatValue);
147147
impl_try_from_basic_value_enum!(PointerValue);
148148
impl_try_from_basic_value_enum!(StructValue);
149149
impl_try_from_basic_value_enum!(VectorValue);
150-
151-
macro_rules! impl_try_from_basic_type_enum {
152-
($type_name:ident) => (
153-
impl TryFrom<BasicTypeEnum> for $type_name {
154-
type Error = &'static str;
155-
156-
fn try_from(ty: BasicTypeEnum) -> Result<Self, Self::Error> {
157-
match ty {
158-
BasicTypeEnum::$type_name(ty) => Ok(ty),
159-
_ => Err("bad try from"),
160-
}
161-
}
162-
}
163-
)
164-
}
165-
166-
impl_try_from_basic_type_enum!(ArrayType);
167-
impl_try_from_basic_type_enum!(FloatType);
168-
impl_try_from_basic_type_enum!(IntType);
169-
impl_try_from_basic_type_enum!(PointerType);
170-
impl_try_from_basic_type_enum!(StructType);
171-
impl_try_from_basic_type_enum!(VectorType);

0 commit comments

Comments
 (0)