From 0feaccf5260bc59f7ee4294a2ecc875da669ad30 Mon Sep 17 00:00:00 2001 From: Erick Tryzelaar Date: Mon, 16 Sep 2013 21:12:18 -0700 Subject: syntax: Add #[deriving(FromPrimitive)] syntax extension Right now this only works for c-style enums. --- src/libsyntax/ext/build.rs | 27 +++++++ src/libsyntax/ext/deriving/generic.rs | 1 + src/libsyntax/ext/deriving/mod.rs | 4 ++ src/libsyntax/ext/deriving/primitive.rs | 120 ++++++++++++++++++++++++++++++++ 4 files changed, 152 insertions(+) create mode 100644 src/libsyntax/ext/deriving/primitive.rs (limited to 'src/libsyntax') diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index 5111682f6d0..8e4f553cb83 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -113,6 +113,7 @@ pub trait AstBuilder { expr: @ast::Expr, ident: ast::Ident, args: ~[@ast::Expr]) -> @ast::Expr; fn expr_block(&self, b: ast::Block) -> @ast::Expr; + fn expr_cast(&self, sp: Span, expr: @ast::Expr, ty: ast::Ty) -> @ast::Expr; fn field_imm(&self, span: Span, name: Ident, e: @ast::Expr) -> ast::Field; fn expr_struct(&self, span: Span, path: ast::Path, fields: ~[ast::Field]) -> @ast::Expr; @@ -132,6 +133,9 @@ pub trait AstBuilder { fn expr_str(&self, sp: Span, s: @str) -> @ast::Expr; fn expr_str_uniq(&self, sp: Span, s: @str) -> @ast::Expr; + fn expr_some(&self, sp: Span, expr: @ast::Expr) -> @ast::Expr; + fn expr_none(&self, sp: Span) -> @ast::Expr; + fn expr_unreachable(&self, span: Span) -> @ast::Expr; fn pat(&self, span: Span, pat: ast::Pat_) -> @ast::Pat; @@ -564,6 +568,29 @@ impl AstBuilder for @ExtCtxt { } + fn expr_cast(&self, sp: Span, expr: @ast::Expr, ty: ast::Ty) -> @ast::Expr { + self.expr(sp, ast::ExprCast(expr, ty)) + } + + + fn expr_some(&self, sp: Span, expr: @ast::Expr) -> @ast::Expr { + let some = ~[ + self.ident_of("std"), + self.ident_of("option"), + self.ident_of("Some"), + ]; + self.expr_call_global(sp, some, ~[expr]) + } + + fn expr_none(&self, sp: Span) -> @ast::Expr { + let none = self.path_global(sp, ~[ + self.ident_of("std"), + self.ident_of("option"), + self.ident_of("None"), + ]); + self.expr_path(none) + } + fn expr_unreachable(&self, span: Span) -> @ast::Expr { let loc = self.codemap().lookup_char_pos(span.lo); self.expr_call_global( diff --git a/src/libsyntax/ext/deriving/generic.rs b/src/libsyntax/ext/deriving/generic.rs index f5e45eec7e0..b3fd4f920d8 100644 --- a/src/libsyntax/ext/deriving/generic.rs +++ b/src/libsyntax/ext/deriving/generic.rs @@ -1151,6 +1151,7 @@ pub fn cs_or(enum_nonmatch_f: EnumNonMatchFunc, enum_nonmatch_f, cx, span, substructure) } + /// cs_binop with binop == and #[inline] pub fn cs_and(enum_nonmatch_f: EnumNonMatchFunc, diff --git a/src/libsyntax/ext/deriving/mod.rs b/src/libsyntax/ext/deriving/mod.rs index a428c6704f9..3e65f7bdefb 100644 --- a/src/libsyntax/ext/deriving/mod.rs +++ b/src/libsyntax/ext/deriving/mod.rs @@ -32,6 +32,7 @@ pub mod rand; pub mod to_str; pub mod zero; pub mod default; +pub mod primitive; #[path="cmp/eq.rs"] pub mod eq; @@ -97,9 +98,12 @@ pub fn expand_meta_deriving(cx: @ExtCtxt, "Rand" => expand!(rand::expand_deriving_rand), "ToStr" => expand!(to_str::expand_deriving_to_str), + "Zero" => expand!(zero::expand_deriving_zero), "Default" => expand!(default::expand_deriving_default), + "FromPrimitive" => expand!(primitive::expand_deriving_from_primitive), + ref tname => { cx.span_err(titem.span, format!("unknown \ `deriving` trait: `{}`", *tname)); diff --git a/src/libsyntax/ext/deriving/primitive.rs b/src/libsyntax/ext/deriving/primitive.rs new file mode 100644 index 00000000000..6e012eedfa3 --- /dev/null +++ b/src/libsyntax/ext/deriving/primitive.rs @@ -0,0 +1,120 @@ +// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use ast::{MetaItem, item, Expr}; +use ast; +use codemap::Span; +use ext::base::ExtCtxt; +use ext::build::AstBuilder; +use ext::deriving::generic::*; + +pub fn expand_deriving_from_primitive(cx: @ExtCtxt, + span: Span, + mitem: @MetaItem, + in_items: ~[@item]) -> ~[@item] { + let trait_def = TraitDef { + path: Path::new(~["std", "num", "FromPrimitive"]), + additional_bounds: ~[], + generics: LifetimeBounds::empty(), + methods: ~[ + MethodDef { + name: "from_int", + generics: LifetimeBounds::empty(), + explicit_self: None, + args: ~[ + Literal(Path::new(~["int"])), + ], + ret_ty: Literal(Path::new_(~["std", "option", "Option"], + None, + ~[~Self], + true)), + const_nonmatching: false, + combine_substructure: |c, s, sub| cs_from("int", c, s, sub), + }, + MethodDef { + name: "from_uint", + generics: LifetimeBounds::empty(), + explicit_self: None, + args: ~[ + Literal(Path::new(~["uint"])), + ], + ret_ty: Literal(Path::new_(~["std", "option", "Option"], + None, + ~[~Self], + true)), + const_nonmatching: false, + combine_substructure: |c, s, sub| cs_from("uint", c, s, sub), + }, + ] + }; + + trait_def.expand(cx, span, mitem, in_items) +} + +fn cs_from(name: &str, cx: @ExtCtxt, span: Span, substr: &Substructure) -> @Expr { + let n = match substr.nonself_args { + [n] => n, + _ => cx.span_bug(span, "Incorrect number of arguments in `deriving(FromPrimitive)`") + }; + + return match *substr.fields { + StaticEnum(enum_def, _) => { + if enum_def.variants.is_empty() { + cx.span_fatal(span, "`FromPrimitive` cannot be derived for enums with no variants"); + } + + let mut arms = ~[]; + + for variant in enum_def.variants.iter() { + match variant.node.kind { + ast::tuple_variant_kind(ref args) => { + if !args.is_empty() { + cx.span_fatal(span, "`FromPrimitive` cannot be derived for \ + enum variants with arguments"); + } + + // expr for `$n == $variant as $name` + let variant = cx.expr_ident(span, variant.node.name); + let ty = cx.ty_ident(span, cx.ident_of(name)); + let cast = cx.expr_cast(span, variant, ty); + let guard = cx.expr_binary(span, ast::BiEq, n, cast); + + // expr for `Some($variant)` + let body = cx.expr_some(span, variant); + + // arm for `_ if $guard => $body` + let arm = ast::Arm { + pats: ~[cx.pat_wild(span)], + guard: Some(guard), + body: cx.block_expr(body), + }; + + arms.push(arm); + } + ast::struct_variant_kind(_) => { + cx.span_fatal(span, "`FromPrimitive` cannot be derived for enums \ + with struct variants"); + } + } + } + + // arm for `_ => None` + let arm = ast::Arm { + pats: ~[cx.pat_wild(span)], + guard: None, + body: cx.block_expr(cx.expr_none(span)), + }; + arms.push(arm); + + cx.expr_match(span, n, arms) + } + _ => cx.bug("expected StaticEnum in deriving(FromPrimitive)") + }; +} -- cgit 1.4.1-3-g733a5 From 8f8cc061d9a82f7cfd9b9c9d7312c9551c4b286f Mon Sep 17 00:00:00 2001 From: Erick Tryzelaar Date: Tue, 17 Sep 2013 07:45:49 -0700 Subject: syntax: swap from .span_fatal to .span_err in #[deriving(FromPrimitive)] --- src/libsyntax/ext/build.rs | 9 +++++++-- src/libsyntax/ext/deriving/primitive.rs | 21 ++++++++++++++------- 2 files changed, 21 insertions(+), 9 deletions(-) (limited to 'src/libsyntax') diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index 8e4f553cb83..65a6572fa5e 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -136,6 +136,7 @@ pub trait AstBuilder { fn expr_some(&self, sp: Span, expr: @ast::Expr) -> @ast::Expr; fn expr_none(&self, sp: Span) -> @ast::Expr; + fn expr_fail(&self, span: Span, msg: @str) -> @ast::Expr; fn expr_unreachable(&self, span: Span) -> @ast::Expr; fn pat(&self, span: Span, pat: ast::Pat_) -> @ast::Pat; @@ -591,7 +592,7 @@ impl AstBuilder for @ExtCtxt { self.expr_path(none) } - fn expr_unreachable(&self, span: Span) -> @ast::Expr { + fn expr_fail(&self, span: Span, msg: @str) -> @ast::Expr { let loc = self.codemap().lookup_char_pos(span.lo); self.expr_call_global( span, @@ -602,12 +603,16 @@ impl AstBuilder for @ExtCtxt { self.ident_of("fail_with"), ], ~[ - self.expr_str(span, @"internal error: entered unreachable code"), + self.expr_str(span, msg), self.expr_str(span, loc.file.name), self.expr_uint(span, loc.line), ]) } + fn expr_unreachable(&self, span: Span) -> @ast::Expr { + self.expr_fail(span, @"internal error: entered unreachable code") + } + fn pat(&self, span: Span, pat: ast::Pat_) -> @ast::Pat { @ast::Pat { id: ast::DUMMY_NODE_ID, node: pat, span: span } diff --git a/src/libsyntax/ext/deriving/primitive.rs b/src/libsyntax/ext/deriving/primitive.rs index 6e012eedfa3..ddf8fc404d4 100644 --- a/src/libsyntax/ext/deriving/primitive.rs +++ b/src/libsyntax/ext/deriving/primitive.rs @@ -64,10 +64,15 @@ fn cs_from(name: &str, cx: @ExtCtxt, span: Span, substr: &Substructure) -> @Expr _ => cx.span_bug(span, "Incorrect number of arguments in `deriving(FromPrimitive)`") }; - return match *substr.fields { + match *substr.fields { + StaticStruct(*) => { + cx.span_err(span, "`FromPrimitive` cannot be derived for structs"); + return cx.expr_fail(span, @""); + } StaticEnum(enum_def, _) => { if enum_def.variants.is_empty() { - cx.span_fatal(span, "`FromPrimitive` cannot be derived for enums with no variants"); + cx.span_err(span, "`FromPrimitive` cannot be derived for enums with no variants"); + return cx.expr_fail(span, @""); } let mut arms = ~[]; @@ -76,8 +81,9 @@ fn cs_from(name: &str, cx: @ExtCtxt, span: Span, substr: &Substructure) -> @Expr match variant.node.kind { ast::tuple_variant_kind(ref args) => { if !args.is_empty() { - cx.span_fatal(span, "`FromPrimitive` cannot be derived for \ - enum variants with arguments"); + cx.span_err(span, "`FromPrimitive` cannot be derived for \ + enum variants with arguments"); + return cx.expr_fail(span, @""); } // expr for `$n == $variant as $name` @@ -99,8 +105,9 @@ fn cs_from(name: &str, cx: @ExtCtxt, span: Span, substr: &Substructure) -> @Expr arms.push(arm); } ast::struct_variant_kind(_) => { - cx.span_fatal(span, "`FromPrimitive` cannot be derived for enums \ - with struct variants"); + cx.span_err(span, "`FromPrimitive` cannot be derived for enums \ + with struct variants"); + return cx.expr_fail(span, @""); } } } @@ -116,5 +123,5 @@ fn cs_from(name: &str, cx: @ExtCtxt, span: Span, substr: &Substructure) -> @Expr cx.expr_match(span, n, arms) } _ => cx.bug("expected StaticEnum in deriving(FromPrimitive)") - }; + } } -- cgit 1.4.1-3-g733a5 From 9de7ad2d8c1729b7b11c6d234fc8ef8ce96809bb Mon Sep 17 00:00:00 2001 From: Erick Tryzelaar Date: Tue, 17 Sep 2013 19:28:35 -0700 Subject: std: Swap {To,From}Primitive to use the 64bit as the unimplemented version One downside with this current implementation is that since BigInt's default is now 64 bit, we can convert larger BigInt's to a primitive, however the current implementation on 32 bit architectures does not take advantage of this fact. --- src/libextra/num/bigint.rs | 48 +++++++++++------------ src/libstd/num/num.rs | 68 +++++++++++++++++---------------- src/libsyntax/ext/deriving/primitive.rs | 12 +++--- 3 files changed, 66 insertions(+), 62 deletions(-) (limited to 'src/libsyntax') diff --git a/src/libextra/num/bigint.rs b/src/libextra/num/bigint.rs index 493bbfa14b9..dd2acdb2e14 100644 --- a/src/libextra/num/bigint.rs +++ b/src/libextra/num/bigint.rs @@ -20,13 +20,13 @@ A `BigInt` is a combination of `BigUint` and `Sign`. #[allow(non_uppercase_statics)]; use std::cmp::{Eq, Ord, TotalEq, TotalOrd, Ordering, Less, Equal, Greater}; -use std::int; use std::num; use std::num::{Zero, One, ToStrRadix, FromStrRadix, Orderable}; use std::num::{ToPrimitive, FromPrimitive}; use std::rand::Rng; use std::str; use std::uint; +use std::{i64, u64}; use std::vec; /** @@ -503,24 +503,24 @@ impl Integer for BigUint { impl ToPrimitive for BigUint { #[inline] - fn to_int(&self) -> Option { + fn to_i64(&self) -> Option { do self.to_uint().and_then |n| { - // If top bit of uint is set, it's too large to convert to + // If top bit of u64 is set, it's too large to convert to // int. if (n >> (2*BigDigit::bits - 1) != 0) { None } else { - Some(n as int) + Some(n as i64) } } } #[inline] - fn to_uint(&self) -> Option { + fn to_u64(&self) -> Option { match self.data.len() { 0 => Some(0), - 1 => Some(self.data[0] as uint), - 2 => Some(BigDigit::to_uint(self.data[1], self.data[0])), + 1 => Some(self.data[0] as u64), + 2 => Some(BigDigit::to_uint(self.data[1], self.data[0]) as u64), _ => None } } @@ -528,17 +528,17 @@ impl ToPrimitive for BigUint { impl FromPrimitive for BigUint { #[inline] - fn from_int(n: int) -> Option { + fn from_i64(n: i64) -> Option { if (n < 0) { Some(Zero::zero()) } else { - FromPrimitive::from_uint(n as uint) + FromPrimitive::from_u64(n as u64) } } #[inline] - fn from_uint(n: uint) -> Option { - let n = match BigDigit::from_uint(n) { + fn from_u64(n: u64) -> Option { + let n = match BigDigit::from_uint(n as uint) { (0, 0) => Zero::zero(), (0, n0) => BigUint::new(~[n0]), (n1, n0) => BigUint::new(~[n0, n1]) @@ -1083,19 +1083,19 @@ impl Integer for BigInt { impl ToPrimitive for BigInt { #[inline] - fn to_int(&self) -> Option { + fn to_i64(&self) -> Option { match self.sign { - Plus => self.data.to_int(), + Plus => self.data.to_i64(), Zero => Some(0), Minus => { - do self.data.to_uint().and_then |n| { - let m: uint = 1 << (2*BigDigit::bits-1); + do self.data.to_u64().and_then |n| { + let m: u64 = 1 << (2*BigDigit::bits-1); if (n > m) { None } else if (n == m) { - Some(int::min_value) + Some(i64::min_value) } else { - Some(-(n as int)) + Some(-(n as i64)) } } } @@ -1103,9 +1103,9 @@ impl ToPrimitive for BigInt { } #[inline] - fn to_uint(&self) -> Option { + fn to_u64(&self) -> Option { match self.sign { - Plus => self.data.to_uint(), + Plus => self.data.to_u64(), Zero => Some(0), Minus => None } @@ -1114,13 +1114,13 @@ impl ToPrimitive for BigInt { impl FromPrimitive for BigInt { #[inline] - fn from_int(n: int) -> Option { + fn from_i64(n: i64) -> Option { if n > 0 { - do FromPrimitive::from_uint(n as uint).and_then |n| { + do FromPrimitive::from_u64(n as u64).and_then |n| { Some(BigInt::from_biguint(Plus, n)) } } else if n < 0 { - do FromPrimitive::from_uint(uint::max_value - (n as uint) + 1).and_then |n| { + do FromPrimitive::from_u64(u64::max_value - (n as u64) + 1).and_then |n| { Some(BigInt::from_biguint(Minus, n)) } } else { @@ -1129,11 +1129,11 @@ impl FromPrimitive for BigInt { } #[inline] - fn from_uint(n: uint) -> Option { + fn from_u64(n: u64) -> Option { if n == 0 { Some(Zero::zero()) } else { - do FromPrimitive::from_uint(n).and_then |n| { + do FromPrimitive::from_u64(n).and_then |n| { Some(BigInt::from_biguint(Plus, n)) } } diff --git a/src/libstd/num/num.rs b/src/libstd/num/num.rs index a8c85184664..fffa9b49699 100644 --- a/src/libstd/num/num.rs +++ b/src/libstd/num/num.rs @@ -351,65 +351,69 @@ pub trait Float: Real /// A generic trait for converting a value to a number. pub trait ToPrimitive { /// Converts the value of `self` to an `int`. - fn to_int(&self) -> Option; + #[inline] + fn to_int(&self) -> Option { + // XXX: Check for range. + self.to_i64().and_then(|x| Some(x as int)) + } /// Converts the value of `self` to an `i8`. #[inline] fn to_i8(&self) -> Option { // XXX: Check for range. - self.to_int().and_then(|x| Some(x as i8)) + self.to_i64().and_then(|x| Some(x as i8)) } /// Converts the value of `self` to an `i16`. #[inline] fn to_i16(&self) -> Option { // XXX: Check for range. - self.to_int().and_then(|x| Some(x as i16)) + self.to_i64().and_then(|x| Some(x as i16)) } /// Converts the value of `self` to an `i32`. #[inline] fn to_i32(&self) -> Option { // XXX: Check for range. - self.to_int().and_then(|x| Some(x as i32)) + self.to_i64().and_then(|x| Some(x as i32)) } /// Converts the value of `self` to an `i64`. + fn to_i64(&self) -> Option; + + /// Converts the value of `self` to an `uint`. #[inline] - fn to_i64(&self) -> Option { + fn to_uint(&self) -> Option { // XXX: Check for range. - self.to_int().and_then(|x| Some(x as i64)) + self.to_u64().and_then(|x| Some(x as uint)) } - /// Converts the value of `self` to an `uint`. - fn to_uint(&self) -> Option; - /// Converts the value of `self` to an `u8`. #[inline] fn to_u8(&self) -> Option { // XXX: Check for range. - self.to_uint().and_then(|x| Some(x as u8)) + self.to_u64().and_then(|x| Some(x as u8)) } /// Converts the value of `self` to an `u16`. #[inline] fn to_u16(&self) -> Option { // XXX: Check for range. - self.to_uint().and_then(|x| Some(x as u16)) + self.to_u64().and_then(|x| Some(x as u16)) } /// Converts the value of `self` to an `u32`. #[inline] fn to_u32(&self) -> Option { // XXX: Check for range. - self.to_uint().and_then(|x| Some(x as u32)) + self.to_u64().and_then(|x| Some(x as u32)) } /// Converts the value of `self` to an `u64`. #[inline] fn to_u64(&self) -> Option { // XXX: Check for range. - self.to_uint().and_then(|x| Some(x as u64)) + self.to_u64().and_then(|x| Some(x as u64)) } /// Converts the value of `self` to an `f32`. @@ -423,7 +427,7 @@ pub trait ToPrimitive { #[inline] fn to_f64(&self) -> Option { // XXX: Check for range. - self.to_float().and_then(|x| Some(x as f64)) + self.to_i64().and_then(|x| Some(x as f64)) } } @@ -467,80 +471,80 @@ impl_to_primitive!(float) pub trait FromPrimitive { /// Convert an `int` to return an optional value of this type. If the /// value cannot be represented by this value, the `None` is returned. - fn from_int(n: int) -> Option; + #[inline] + fn from_int(n: int) -> Option { + FromPrimitive::from_i64(n as i64) + } /// Convert an `i8` to return an optional value of this type. If the /// type cannot be represented by this value, the `None` is returned. #[inline] fn from_i8(n: i8) -> Option { - FromPrimitive::from_int(n as int) + FromPrimitive::from_i64(n as i64) } /// Convert an `i16` to return an optional value of this type. If the /// type cannot be represented by this value, the `None` is returned. #[inline] fn from_i16(n: i16) -> Option { - FromPrimitive::from_int(n as int) + FromPrimitive::from_i64(n as i64) } /// Convert an `i32` to return an optional value of this type. If the /// type cannot be represented by this value, the `None` is returned. #[inline] fn from_i32(n: i32) -> Option { - FromPrimitive::from_int(n as int) + FromPrimitive::from_i64(n as i64) } /// Convert an `i64` to return an optional value of this type. If the /// type cannot be represented by this value, the `None` is returned. - #[inline] - fn from_i64(n: i64) -> Option { - FromPrimitive::from_int(n as int) - } + fn from_i64(n: i64) -> Option; /// Convert an `uint` to return an optional value of this type. If the /// type cannot be represented by this value, the `None` is returned. - fn from_uint(n: uint) -> Option; + #[inline] + fn from_uint(n: uint) -> Option { + FromPrimitive::from_u64(n as u64) + } /// Convert an `u8` to return an optional value of this type. If the /// type cannot be represented by this value, the `None` is returned. #[inline] fn from_u8(n: u8) -> Option { - FromPrimitive::from_uint(n as uint) + FromPrimitive::from_u64(n as u64) } /// Convert an `u16` to return an optional value of this type. If the /// type cannot be represented by this value, the `None` is returned. #[inline] fn from_u16(n: u16) -> Option { - FromPrimitive::from_uint(n as uint) + FromPrimitive::from_u64(n as u64) } /// Convert an `u32` to return an optional value of this type. If the /// type cannot be represented by this value, the `None` is returned. #[inline] fn from_u32(n: u32) -> Option { - FromPrimitive::from_uint(n as uint) + FromPrimitive::from_u64(n as u64) } /// Convert an `u64` to return an optional value of this type. If the /// type cannot be represented by this value, the `None` is returned. - #[inline] - fn from_u64(n: u64) -> Option { - FromPrimitive::from_uint(n as uint) - } + fn from_u64(n: u64) -> Option; /// Convert a `f32` to return an optional value of this type. If the /// type cannot be represented by this value, the `None` is returned. #[inline] fn from_f32(n: f32) -> Option { - FromPrimitive::from_float(n as float) + FromPrimitive::from_f64(n as f64) } /// Convert a `f64` to return an optional value of this type. If the /// type cannot be represented by this value, the `None` is returned. #[inline] fn from_f64(n: f64) -> Option { - FromPrimitive::from_float(n as float) + FromPrimitive::from_i64(n as i64) } } diff --git a/src/libsyntax/ext/deriving/primitive.rs b/src/libsyntax/ext/deriving/primitive.rs index ddf8fc404d4..38c30def1d1 100644 --- a/src/libsyntax/ext/deriving/primitive.rs +++ b/src/libsyntax/ext/deriving/primitive.rs @@ -25,32 +25,32 @@ pub fn expand_deriving_from_primitive(cx: @ExtCtxt, generics: LifetimeBounds::empty(), methods: ~[ MethodDef { - name: "from_int", + name: "from_i64", generics: LifetimeBounds::empty(), explicit_self: None, args: ~[ - Literal(Path::new(~["int"])), + Literal(Path::new(~["i64"])), ], ret_ty: Literal(Path::new_(~["std", "option", "Option"], None, ~[~Self], true)), const_nonmatching: false, - combine_substructure: |c, s, sub| cs_from("int", c, s, sub), + combine_substructure: |c, s, sub| cs_from("i64", c, s, sub), }, MethodDef { - name: "from_uint", + name: "from_u64", generics: LifetimeBounds::empty(), explicit_self: None, args: ~[ - Literal(Path::new(~["uint"])), + Literal(Path::new(~["u64"])), ], ret_ty: Literal(Path::new_(~["std", "option", "Option"], None, ~[~Self], true)), const_nonmatching: false, - combine_substructure: |c, s, sub| cs_from("uint", c, s, sub), + combine_substructure: |c, s, sub| cs_from("u64", c, s, sub), }, ] }; -- cgit 1.4.1-3-g733a5