core: Demode option
This commit is contained in:
parent
92752a462a
commit
4a78f9b166
@ -805,7 +805,7 @@ fn install_one_crate(c: &cargo, path: &Path, cf: &Path) {
|
||||
if (exec_suffix != ~"" && str::ends_with(ct.to_str(),
|
||||
exec_suffix)) ||
|
||||
(exec_suffix == ~"" &&
|
||||
!str::starts_with(option::get(ct.filename()),
|
||||
!str::starts_with(ct.filename().get(),
|
||||
~"lib")) {
|
||||
debug!(" bin: %s", ct.to_str());
|
||||
install_to_dir(*ct, &c.bindir);
|
||||
@ -874,8 +874,8 @@ fn install_source(c: &cargo, path: &Path) {
|
||||
|
||||
fn install_git(c: &cargo, wd: &Path, url: ~str, reference: Option<~str>) {
|
||||
run::program_output(~"git", ~[~"clone", url, wd.to_str()]);
|
||||
if option::is_some(reference) {
|
||||
let r = option::get(reference);
|
||||
if reference.is_some() {
|
||||
let r = reference.get();
|
||||
os::change_dir(wd);
|
||||
run::run_program(~"git", ~[~"checkout", r]);
|
||||
}
|
||||
@ -1597,7 +1597,7 @@ fn cmd_search(c: &cargo) {
|
||||
}
|
||||
|
||||
fn install_to_dir(srcfile: &Path, destdir: &Path) {
|
||||
let newfile = destdir.push(option::get(srcfile.filename()));
|
||||
let newfile = destdir.push(srcfile.filename().get());
|
||||
|
||||
let status = run::run_program(~"cp", ~[~"-r", srcfile.to_str(),
|
||||
newfile.to_str()]);
|
||||
|
@ -56,7 +56,7 @@ fn parse_config(args: ~[~str]) -> config {
|
||||
if vec::len(matches.free) > 0u {
|
||||
option::Some(matches.free[0])
|
||||
} else { option::None },
|
||||
logfile: option::map(getopts::opt_maybe_str(matches,
|
||||
logfile: option::map(&getopts::opt_maybe_str(matches,
|
||||
~"logfile"),
|
||||
|s| Path(s)),
|
||||
runtool: getopts::opt_maybe_str(matches, ~"runtool"),
|
||||
@ -155,7 +155,7 @@ fn is_test(config: config, testfile: &Path) -> bool {
|
||||
_ => ~[~".rc", ~".rs"]
|
||||
};
|
||||
let invalid_prefixes = ~[~".", ~"#", ~"~"];
|
||||
let name = option::get(testfile.filename());
|
||||
let name = testfile.filename().get();
|
||||
|
||||
let mut valid = false;
|
||||
|
||||
|
@ -32,19 +32,19 @@ fn load_props(testfile: &Path) -> test_props {
|
||||
option::None => ()
|
||||
};
|
||||
|
||||
if option::is_none(compile_flags) {
|
||||
if compile_flags.is_none() {
|
||||
compile_flags = parse_compile_flags(ln);
|
||||
}
|
||||
|
||||
if option::is_none(pp_exact) {
|
||||
if pp_exact.is_none() {
|
||||
pp_exact = parse_pp_exact(ln, testfile);
|
||||
}
|
||||
|
||||
do option::iter(parse_aux_build(ln)) |ab| {
|
||||
do parse_aux_build(ln).iter |ab| {
|
||||
vec::push(aux_builds, ab);
|
||||
}
|
||||
|
||||
do option::iter(parse_exec_env(ln)) |ee| {
|
||||
do parse_exec_env(ln).iter |ee| {
|
||||
vec::push(exec_env, ee);
|
||||
}
|
||||
};
|
||||
|
@ -89,9 +89,9 @@ fn run(lib_path: ~str,
|
||||
}
|
||||
|
||||
fn writeclose(fd: c_int, s: Option<~str>) {
|
||||
if option::is_some(s) {
|
||||
if s.is_some() {
|
||||
let writer = io::fd_writer(fd, false);
|
||||
writer.write_str(option::get(s));
|
||||
writer.write_str(s.get());
|
||||
}
|
||||
|
||||
os::close(fd);
|
||||
|
@ -102,7 +102,7 @@ fn run_rpass_test(config: config, props: test_props, testfile: &Path) {
|
||||
}
|
||||
|
||||
fn run_pretty_test(config: config, props: test_props, testfile: &Path) {
|
||||
if option::is_some(props.pp_exact) {
|
||||
if props.pp_exact.is_some() {
|
||||
logv(config, ~"testing for exact pretty-printing");
|
||||
} else { logv(config, ~"testing for converging pretty-printing"); }
|
||||
|
||||
@ -135,7 +135,7 @@ fn run_pretty_test(config: config, props: test_props, testfile: &Path) {
|
||||
};
|
||||
let mut actual = srcs[vec::len(srcs) - 1u];
|
||||
|
||||
if option::is_some(props.pp_exact) {
|
||||
if props.pp_exact.is_some() {
|
||||
// Now we have to care about line endings
|
||||
let cr = ~"\r";
|
||||
actual = str::replace(actual, cr, ~"");
|
||||
@ -575,7 +575,7 @@ fn aux_output_dir_name(config: config, testfile: &Path) -> Path {
|
||||
}
|
||||
|
||||
fn output_testname(testfile: &Path) -> Path {
|
||||
Path(option::get(testfile.filestem()))
|
||||
Path(testfile.filestem().get())
|
||||
}
|
||||
|
||||
fn output_base_name(config: config, testfile: &Path) -> Path {
|
||||
|
@ -305,7 +305,7 @@ fn check_variants_T<T: Copy>(
|
||||
}
|
||||
|
||||
fn last_part(filename: ~str) -> ~str {
|
||||
let ix = option::get(str::rfind_char(filename, '/'));
|
||||
let ix = option::get(&str::rfind_char(filename, '/'));
|
||||
str::slice(filename, ix + 1u, str::len(filename) - 3u)
|
||||
}
|
||||
|
||||
|
@ -211,7 +211,7 @@ impl<T> DList<T> {
|
||||
fn push_head_n(+data: T) -> DListNode<T> {
|
||||
let mut nobe = self.new_link(move data);
|
||||
self.add_head(nobe);
|
||||
option::get(nobe)
|
||||
option::get(&nobe)
|
||||
}
|
||||
/// Add data to the tail of the list. O(1).
|
||||
fn push(+data: T) {
|
||||
@ -224,7 +224,7 @@ impl<T> DList<T> {
|
||||
fn push_n(+data: T) -> DListNode<T> {
|
||||
let mut nobe = self.new_link(move data);
|
||||
self.add_tail(nobe);
|
||||
option::get(nobe)
|
||||
option::get(&nobe)
|
||||
}
|
||||
/**
|
||||
* Insert data into the middle of the list, left of the given node.
|
||||
@ -248,7 +248,7 @@ impl<T> DList<T> {
|
||||
fn insert_before_n(+data: T, neighbour: DListNode<T>) -> DListNode<T> {
|
||||
let mut nobe = self.new_link(move data);
|
||||
self.insert_left(nobe, neighbour);
|
||||
option::get(nobe)
|
||||
option::get(&nobe)
|
||||
}
|
||||
/**
|
||||
* Insert data into the middle of the list, right of the given node.
|
||||
@ -272,7 +272,7 @@ impl<T> DList<T> {
|
||||
fn insert_after_n(+data: T, neighbour: DListNode<T>) -> DListNode<T> {
|
||||
let mut nobe = self.new_link(move data);
|
||||
self.insert_right(neighbour, nobe);
|
||||
option::get(nobe)
|
||||
option::get(&nobe)
|
||||
}
|
||||
|
||||
/// Remove a node from the head of the list. O(1).
|
||||
@ -380,21 +380,25 @@ impl<T> DList<T> {
|
||||
|
||||
/// Check data structure integrity. O(n).
|
||||
fn assert_consistent() {
|
||||
if option::is_none(self.hd) || option::is_none(self.tl) {
|
||||
assert option::is_none(self.hd) && option::is_none(self.tl);
|
||||
if option::is_none(&self.hd) || option::is_none(&self.tl) {
|
||||
assert option::is_none(&self.hd) && option::is_none(&self.tl);
|
||||
}
|
||||
// iterate forwards
|
||||
let mut count = 0;
|
||||
let mut link = self.peek_n();
|
||||
let mut rabbit = link;
|
||||
while option::is_some(link) {
|
||||
let nobe = option::get(link);
|
||||
while option::is_some(&link) {
|
||||
let nobe = option::get(&link);
|
||||
assert nobe.linked;
|
||||
// check cycle
|
||||
if option::is_some(rabbit) { rabbit = option::get(rabbit).next; }
|
||||
if option::is_some(rabbit) { rabbit = option::get(rabbit).next; }
|
||||
if option::is_some(rabbit) {
|
||||
assert !box::ptr_eq(*option::get(rabbit), *nobe);
|
||||
if option::is_some(&rabbit) {
|
||||
rabbit = option::get(&rabbit).next;
|
||||
}
|
||||
if option::is_some(&rabbit) {
|
||||
rabbit = option::get(&rabbit).next;
|
||||
}
|
||||
if option::is_some(&rabbit) {
|
||||
assert !box::ptr_eq(*option::get(&rabbit), *nobe);
|
||||
}
|
||||
// advance
|
||||
link = nobe.next_link();
|
||||
@ -404,14 +408,18 @@ impl<T> DList<T> {
|
||||
// iterate backwards - some of this is probably redundant.
|
||||
link = self.peek_tail_n();
|
||||
rabbit = link;
|
||||
while option::is_some(link) {
|
||||
let nobe = option::get(link);
|
||||
while option::is_some(&link) {
|
||||
let nobe = option::get(&link);
|
||||
assert nobe.linked;
|
||||
// check cycle
|
||||
if option::is_some(rabbit) { rabbit = option::get(rabbit).prev; }
|
||||
if option::is_some(rabbit) { rabbit = option::get(rabbit).prev; }
|
||||
if option::is_some(rabbit) {
|
||||
assert !box::ptr_eq(*option::get(rabbit), *nobe);
|
||||
if option::is_some(&rabbit) {
|
||||
rabbit = option::get(&rabbit).prev;
|
||||
}
|
||||
if option::is_some(&rabbit) {
|
||||
rabbit = option::get(&rabbit).prev;
|
||||
}
|
||||
if option::is_some(&rabbit) {
|
||||
assert !box::ptr_eq(*option::get(&rabbit), *nobe);
|
||||
}
|
||||
// advance
|
||||
link = nobe.prev_link();
|
||||
|
@ -328,7 +328,7 @@ fn cleanup_stack_for_failure() {
|
||||
let mut roots = ~RootSet();
|
||||
for walk_gc_roots(need_cleanup, sentinel) |root, tydesc| {
|
||||
// Track roots to avoid double frees.
|
||||
if option::is_some(roots.find(&*root)) {
|
||||
if roots.find(&*root).is_some() {
|
||||
loop;
|
||||
}
|
||||
roots.insert(*root, ());
|
||||
|
@ -10,8 +10,8 @@ type IMPL_T<A> = dlist::DList<A>;
|
||||
*/
|
||||
pure fn EACH<A>(self: IMPL_T<A>, f: fn(v: &A) -> bool) {
|
||||
let mut link = self.peek_n();
|
||||
while option::is_some(link) {
|
||||
let nobe = option::get(link);
|
||||
while option::is_some(&link) {
|
||||
let nobe = option::get(&link);
|
||||
assert nobe.linked;
|
||||
if !f(&nobe.data) { break; }
|
||||
// Check (weakly) that the user didn't do a remove.
|
||||
|
@ -8,6 +8,10 @@
|
||||
* type.
|
||||
*/
|
||||
|
||||
// NB: transitionary, de-mode-ing.
|
||||
#[forbid(deprecated_mode)];
|
||||
#[forbid(deprecated_pattern)];
|
||||
|
||||
use cmp::Eq;
|
||||
|
||||
/// The option type
|
||||
@ -16,7 +20,7 @@ enum Option<T> {
|
||||
Some(T),
|
||||
}
|
||||
|
||||
pure fn get<T: Copy>(opt: Option<T>) -> T {
|
||||
pure fn get<T: Copy>(opt: &Option<T>) -> T {
|
||||
/*!
|
||||
* Gets the value out of an option
|
||||
*
|
||||
@ -25,7 +29,7 @@ pure fn get<T: Copy>(opt: Option<T>) -> T {
|
||||
* Fails if the value equals `none`
|
||||
*/
|
||||
|
||||
match opt {
|
||||
match *opt {
|
||||
Some(x) => return x,
|
||||
None => fail ~"option::get none"
|
||||
}
|
||||
@ -45,7 +49,7 @@ pure fn get_ref<T>(opt: &r/Option<T>) -> &r/T {
|
||||
}
|
||||
}
|
||||
|
||||
pure fn expect<T: Copy>(opt: Option<T>, reason: ~str) -> T {
|
||||
pure fn expect<T: Copy>(opt: &Option<T>, +reason: ~str) -> T {
|
||||
/*!
|
||||
* Gets the value out of an option, printing a specified message on
|
||||
* failure
|
||||
@ -54,13 +58,13 @@ pure fn expect<T: Copy>(opt: Option<T>, reason: ~str) -> T {
|
||||
*
|
||||
* Fails if the value equals `none`
|
||||
*/
|
||||
match opt { Some(x) => x, None => fail reason }
|
||||
match *opt { Some(x) => x, None => fail reason }
|
||||
}
|
||||
|
||||
pure fn map<T, U>(opt: Option<T>, f: fn(T) -> U) -> Option<U> {
|
||||
pure fn map<T, U>(opt: &Option<T>, f: fn(T) -> U) -> Option<U> {
|
||||
//! Maps a `some` value from one type to another
|
||||
|
||||
match opt { Some(x) => Some(f(x)), None => None }
|
||||
match *opt { Some(x) => Some(f(x)), None => None }
|
||||
}
|
||||
|
||||
pure fn map_ref<T, U>(opt: &Option<T>, f: fn(x: &T) -> U) -> Option<U> {
|
||||
@ -77,13 +81,13 @@ pure fn map_consume<T, U>(+opt: Option<T>, f: fn(+v: T) -> U) -> Option<U> {
|
||||
if opt.is_some() { Some(f(option::unwrap(move opt))) } else { None }
|
||||
}
|
||||
|
||||
pure fn chain<T, U>(opt: Option<T>, f: fn(T) -> Option<U>) -> Option<U> {
|
||||
pure fn chain<T, U>(opt: &Option<T>, f: fn(T) -> Option<U>) -> Option<U> {
|
||||
/*!
|
||||
* Update an optional value by optionally running its content through a
|
||||
* function that returns an option.
|
||||
*/
|
||||
|
||||
match opt { Some(x) => f(x), None => None }
|
||||
match *opt { Some(x) => f(x), None => None }
|
||||
}
|
||||
|
||||
pure fn chain_ref<T, U>(opt: &Option<T>,
|
||||
@ -116,28 +120,28 @@ pure fn while_some<T>(+x: Option<T>, blk: fn(+v: T) -> Option<T>) {
|
||||
}
|
||||
}
|
||||
|
||||
pure fn is_none<T>(opt: Option<T>) -> bool {
|
||||
pure fn is_none<T>(opt: &Option<T>) -> bool {
|
||||
//! Returns true if the option equals `none`
|
||||
|
||||
match opt { None => true, Some(_) => false }
|
||||
match *opt { None => true, Some(_) => false }
|
||||
}
|
||||
|
||||
pure fn is_some<T>(opt: Option<T>) -> bool {
|
||||
pure fn is_some<T>(opt: &Option<T>) -> bool {
|
||||
//! Returns true if the option contains some value
|
||||
|
||||
!is_none(opt)
|
||||
}
|
||||
|
||||
pure fn get_default<T: Copy>(opt: Option<T>, def: T) -> T {
|
||||
pure fn get_default<T: Copy>(opt: &Option<T>, +def: T) -> T {
|
||||
//! Returns the contained value or a default
|
||||
|
||||
match opt { Some(x) => x, None => def }
|
||||
match *opt { Some(x) => x, None => def }
|
||||
}
|
||||
|
||||
pure fn map_default<T, U>(opt: Option<T>, +def: U, f: fn(T) -> U) -> U {
|
||||
pure fn map_default<T, U>(opt: &Option<T>, +def: U, f: fn(T) -> U) -> U {
|
||||
//! Applies a function to the contained value or returns a default
|
||||
|
||||
match opt { None => move def, Some(t) => f(t) }
|
||||
match *opt { None => move def, Some(t) => f(t) }
|
||||
}
|
||||
|
||||
// This should replace map_default.
|
||||
@ -149,10 +153,10 @@ pure fn map_default_ref<T, U>(opt: &Option<T>, +def: U,
|
||||
}
|
||||
|
||||
// This should change to by-copy mode; use iter_ref below for by reference
|
||||
pure fn iter<T>(opt: Option<T>, f: fn(T)) {
|
||||
pure fn iter<T>(opt: &Option<T>, f: fn(T)) {
|
||||
//! Performs an operation on the contained value or does nothing
|
||||
|
||||
match opt { None => (), Some(t) => f(t) }
|
||||
match *opt { None => (), Some(t) => f(t) }
|
||||
}
|
||||
|
||||
pure fn iter_ref<T>(opt: &Option<T>, f: fn(x: &T)) {
|
||||
@ -163,7 +167,7 @@ pure fn iter_ref<T>(opt: &Option<T>, f: fn(x: &T)) {
|
||||
// tjc: shouldn't this be - instead of +?
|
||||
// then could get rid of some superfluous moves
|
||||
#[inline(always)]
|
||||
pure fn unwrap<T>(-opt: Option<T>) -> T {
|
||||
pure fn unwrap<T>(+opt: Option<T>) -> T {
|
||||
/*!
|
||||
* Moves a value out of an option type and returns it.
|
||||
*
|
||||
@ -195,18 +199,18 @@ impl<T> Option<T> {
|
||||
* Update an optional value by optionally running its content through a
|
||||
* function that returns an option.
|
||||
*/
|
||||
pure fn chain<U>(f: fn(T) -> Option<U>) -> Option<U> { chain(self, f) }
|
||||
pure fn chain<U>(f: fn(T) -> Option<U>) -> Option<U> { chain(&self, f) }
|
||||
/// Applies a function to the contained value or returns a default
|
||||
pure fn map_default<U>(+def: U, f: fn(T) -> U) -> U
|
||||
{ map_default(self, move def, f) }
|
||||
{ map_default(&self, move def, f) }
|
||||
/// Performs an operation on the contained value or does nothing
|
||||
pure fn iter(f: fn(T)) { iter(self, f) }
|
||||
pure fn iter(f: fn(T)) { iter(&self, f) }
|
||||
/// Returns true if the option equals `none`
|
||||
pure fn is_none() -> bool { is_none(self) }
|
||||
pure fn is_none() -> bool { is_none(&self) }
|
||||
/// Returns true if the option contains some value
|
||||
pure fn is_some() -> bool { is_some(self) }
|
||||
pure fn is_some() -> bool { is_some(&self) }
|
||||
/// Maps a `some` value from one type to another
|
||||
pure fn map<U>(f: fn(T) -> U) -> Option<U> { map(self, f) }
|
||||
pure fn map<U>(f: fn(T) -> U) -> Option<U> { map(&self, f) }
|
||||
}
|
||||
|
||||
impl<T> &Option<T> {
|
||||
@ -236,8 +240,8 @@ impl<T: Copy> Option<T> {
|
||||
*
|
||||
* Fails if the value equals `none`
|
||||
*/
|
||||
pure fn get() -> T { get(self) }
|
||||
pure fn get_default(def: T) -> T { get_default(self, def) }
|
||||
pure fn get() -> T { get(&self) }
|
||||
pure fn get_default(+def: T) -> T { get_default(&self, def) }
|
||||
/**
|
||||
* Gets the value out of an option, printing a specified message on
|
||||
* failure
|
||||
@ -246,7 +250,7 @@ impl<T: Copy> Option<T> {
|
||||
*
|
||||
* Fails if the value equals `none`
|
||||
*/
|
||||
pure fn expect(reason: ~str) -> T { expect(self, reason) }
|
||||
pure fn expect(+reason: ~str) -> T { expect(&self, reason) }
|
||||
/// Applies a function zero or more times until the result is none.
|
||||
pure fn while_some(blk: fn(+v: T) -> Option<T>) { while_some(self, blk) }
|
||||
}
|
||||
|
@ -438,7 +438,7 @@ fn self_exe_path() -> Option<Path> {
|
||||
}
|
||||
}
|
||||
|
||||
do option::map(load_self()) |pth| {
|
||||
do load_self().map |pth| {
|
||||
Path(pth).dir_path()
|
||||
}
|
||||
}
|
||||
@ -512,7 +512,7 @@ fn tmpdir() -> Path {
|
||||
#[cfg(unix)]
|
||||
#[allow(non_implicitly_copyable_typarams)]
|
||||
fn lookup() -> Path {
|
||||
option::get_default(getenv_nonempty("TMPDIR"),
|
||||
option::get_default(&getenv_nonempty("TMPDIR"),
|
||||
Path("/tmp"))
|
||||
}
|
||||
|
||||
@ -520,7 +520,7 @@ fn tmpdir() -> Path {
|
||||
#[allow(non_implicitly_copyable_typarams)]
|
||||
fn lookup() -> Path {
|
||||
option::get_default(
|
||||
option::or(getenv_nonempty("TMP"),
|
||||
&option::or(getenv_nonempty("TMP"),
|
||||
option::or(getenv_nonempty("TEMP"),
|
||||
option::or(getenv_nonempty("USERPROFILE"),
|
||||
getenv_nonempty("WINDIR")))),
|
||||
@ -848,7 +848,7 @@ mod tests {
|
||||
fn make_rand_name() -> ~str {
|
||||
let rng: rand::Rng = rand::Rng();
|
||||
let n = ~"TEST" + rng.gen_str(10u);
|
||||
assert option::is_none(getenv(n));
|
||||
assert getenv(n).is_none();
|
||||
n
|
||||
}
|
||||
|
||||
@ -889,8 +889,8 @@ mod tests {
|
||||
#[test]
|
||||
fn test_self_exe_path() {
|
||||
let path = os::self_exe_path();
|
||||
assert option::is_some(path);
|
||||
let path = option::get(path);
|
||||
assert path.is_some();
|
||||
let path = path.get();
|
||||
log(debug, path);
|
||||
|
||||
// Hard to test this function
|
||||
@ -909,7 +909,7 @@ mod tests {
|
||||
// MingW seems to set some funky environment variables like
|
||||
// "=C:=C:\MinGW\msys\1.0\bin" and "!::=::\" that are returned
|
||||
// from env() but not visible from getenv().
|
||||
assert option::is_none(v2) || v2 == option::Some(v);
|
||||
assert v2.is_none() || v2 == option::Some(v);
|
||||
}
|
||||
}
|
||||
|
||||
@ -946,7 +946,7 @@ mod tests {
|
||||
setenv(~"HOME", ~"");
|
||||
assert os::homedir().is_none();
|
||||
|
||||
option::iter(oldhome, |s| setenv(~"HOME", s));
|
||||
oldhome.iter(|s| setenv(~"HOME", s));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -1466,7 +1466,7 @@ pure fn find_str_between(haystack: &a/str, needle: &b/str, start: uint,
|
||||
* * needle - The string to look for
|
||||
*/
|
||||
pure fn contains(haystack: &a/str, needle: &b/str) -> bool {
|
||||
option::is_some(find_str(haystack, needle))
|
||||
find_str(haystack, needle).is_some()
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1478,7 +1478,7 @@ pure fn contains(haystack: &a/str, needle: &b/str) -> bool {
|
||||
* * needle - The char to look for
|
||||
*/
|
||||
pure fn contains_char(haystack: &str, needle: char) -> bool {
|
||||
option::is_some(find_char(haystack, needle))
|
||||
find_char(haystack, needle).is_some()
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -957,7 +957,7 @@ pure fn find<T: Copy>(v: &[T], f: fn(T) -> bool) -> Option<T> {
|
||||
*/
|
||||
pure fn find_between<T: Copy>(v: &[T], start: uint, end: uint,
|
||||
f: fn(T) -> bool) -> Option<T> {
|
||||
option::map(position_between(v, start, end, f), |i| v[i])
|
||||
position_between(v, start, end, f).map(|i| v[i])
|
||||
}
|
||||
|
||||
/**
|
||||
@ -980,7 +980,7 @@ pure fn rfind<T: Copy>(v: &[T], f: fn(T) -> bool) -> Option<T> {
|
||||
*/
|
||||
pure fn rfind_between<T: Copy>(v: &[T], start: uint, end: uint,
|
||||
f: fn(T) -> bool) -> Option<T> {
|
||||
option::map(rposition_between(v, start, end, f), |i| v[i])
|
||||
rposition_between(v, start, end, f).map(|i| v[i])
|
||||
}
|
||||
|
||||
/// Find the first index containing a matching value
|
||||
|
@ -303,8 +303,8 @@ fn getopts(args: &[~str], opts: &[Opt]) -> Result unsafe {
|
||||
Some(id) => last_valid_opt_id = option::Some(id),
|
||||
None => {
|
||||
let arg_follows =
|
||||
option::is_some(last_valid_opt_id) &&
|
||||
match opts[option::get(last_valid_opt_id)]
|
||||
last_valid_opt_id.is_some() &&
|
||||
match opts[last_valid_opt_id.get()]
|
||||
.hasarg {
|
||||
|
||||
Yes | Maybe => true,
|
||||
@ -331,23 +331,23 @@ fn getopts(args: &[~str], opts: &[Opt]) -> Result unsafe {
|
||||
};
|
||||
match opts[optid].hasarg {
|
||||
No => {
|
||||
if !option::is_none::<~str>(i_arg) {
|
||||
if !i_arg.is_none() {
|
||||
return Err(UnexpectedArgument(name_str(nm)));
|
||||
}
|
||||
vec::push(vals[optid], Given);
|
||||
}
|
||||
Maybe => {
|
||||
if !option::is_none::<~str>(i_arg) {
|
||||
vec::push(vals[optid], Val(option::get(i_arg)));
|
||||
if !i_arg.is_none() {
|
||||
vec::push(vals[optid], Val(i_arg.get()));
|
||||
} else if name_pos < vec::len::<Name>(names) ||
|
||||
i + 1u == l || is_arg(args[i + 1u]) {
|
||||
vec::push(vals[optid], Given);
|
||||
} else { i += 1u; vec::push(vals[optid], Val(args[i])); }
|
||||
}
|
||||
Yes => {
|
||||
if !option::is_none::<~str>(i_arg) {
|
||||
if !i_arg.is_none() {
|
||||
vec::push(vals[optid],
|
||||
Val(option::get::<~str>(i_arg)));
|
||||
Val(i_arg.get()));
|
||||
} else if i + 1u == l {
|
||||
return Err(ArgumentMissing(name_str(nm)));
|
||||
} else { i += 1u; vec::push(vals[optid], Val(args[i])); }
|
||||
|
@ -730,9 +730,9 @@ mod tests {
|
||||
fn test_find() {
|
||||
let key = ~"k";
|
||||
let map = map::HashMap::<~str, ~str>();
|
||||
assert (option::is_none(map.find(key)));
|
||||
assert (option::is_none(&map.find(key)));
|
||||
map.insert(key, ~"val");
|
||||
assert (option::get(map.find(key)) == ~"val");
|
||||
assert (option::get(&map.find(key)) == ~"val");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -308,7 +308,7 @@ fn userinfo_from_str(uinfo: &str) -> UserInfo {
|
||||
}
|
||||
|
||||
fn userinfo_to_str(+userinfo: UserInfo) -> ~str {
|
||||
if option::is_some(userinfo.pass) {
|
||||
if option::is_some(&userinfo.pass) {
|
||||
return str::concat(~[copy userinfo.user, ~":",
|
||||
option::unwrap(copy userinfo.pass),
|
||||
~"@"]);
|
||||
@ -708,7 +708,7 @@ impl Url : FromStr {
|
||||
*
|
||||
*/
|
||||
fn to_str(+url: Url) -> ~str {
|
||||
let user = if option::is_some(url.user) {
|
||||
let user = if url.user.is_some() {
|
||||
userinfo_to_str(option::unwrap(copy url.user))
|
||||
} else {
|
||||
~""
|
||||
@ -723,7 +723,7 @@ fn to_str(+url: Url) -> ~str {
|
||||
} else {
|
||||
str::concat(~[~"?", query_to_str(url.query)])
|
||||
};
|
||||
let fragment = if option::is_some(url.fragment) {
|
||||
let fragment = if url.fragment.is_some() {
|
||||
str::concat(~[~"#", encode_component(
|
||||
option::unwrap(copy url.fragment))])
|
||||
} else {
|
||||
@ -805,21 +805,21 @@ mod tests {
|
||||
assert u == option::Some({user: ~"user",
|
||||
pass: option::Some(~"pass")});
|
||||
assert h == ~"rust-lang.org";
|
||||
assert option::is_none(p);
|
||||
assert p.is_none();
|
||||
assert r == ~"/something";
|
||||
|
||||
let (u, h, p, r) = result::unwrap(get_authority(
|
||||
~"//rust-lang.org:8000?something"));
|
||||
assert option::is_none(u);
|
||||
assert u.is_none();
|
||||
assert h == ~"rust-lang.org";
|
||||
assert p == option::Some(~"8000");
|
||||
assert r == ~"?something";
|
||||
|
||||
let (u, h, p, r) = result::unwrap(get_authority(
|
||||
~"//rust-lang.org#blah"));
|
||||
assert option::is_none(u);
|
||||
assert u.is_none();
|
||||
assert h == ~"rust-lang.org";
|
||||
assert option::is_none(p);
|
||||
assert p.is_none();
|
||||
assert r == ~"#blah";
|
||||
|
||||
// ipv6 tests
|
||||
|
@ -62,7 +62,7 @@ pure fn get<T: Copy>(self: SmallIntMap<T>, key: uint) -> T {
|
||||
|
||||
/// Returns true if the map contains a value for the specified key
|
||||
fn contains_key<T: Copy>(self: SmallIntMap<T>, key: uint) -> bool {
|
||||
return !option::is_none(find(self, key));
|
||||
return !find(self, key).is_none();
|
||||
}
|
||||
|
||||
/// Implements the map::map interface for smallintmap
|
||||
|
@ -274,8 +274,8 @@ fn should_sort_failures_before_printing_them() {
|
||||
print_failures(st);
|
||||
};
|
||||
|
||||
let apos = option::get(str::find_str(s, ~"a"));
|
||||
let bpos = option::get(str::find_str(s, ~"b"));
|
||||
let apos = str::find_str(s, ~"a").get();
|
||||
let bpos = str::find_str(s, ~"b").get();
|
||||
assert apos < bpos;
|
||||
}
|
||||
|
||||
@ -351,7 +351,7 @@ fn filter_tests(opts: &TestOpts,
|
||||
let mut filtered = vec::slice(tests, 0, tests.len());
|
||||
|
||||
// Remove tests that don't match the test filter
|
||||
filtered = if option::is_none(opts.filter) {
|
||||
filtered = if opts.filter.is_none() {
|
||||
move filtered
|
||||
} else {
|
||||
let filter_str =
|
||||
@ -503,7 +503,7 @@ mod tests {
|
||||
either::Left(o) => o,
|
||||
_ => fail ~"Malformed arg in first_free_arg_should_be_a_filter"
|
||||
};
|
||||
assert ~"filter" == option::get(opts.filter);
|
||||
assert ~"filter" == opts.filter.get();
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -269,8 +269,8 @@ fn highlight_lines(cm: codemap::codemap, sp: span,
|
||||
}
|
||||
|
||||
fn print_macro_backtrace(cm: codemap::codemap, sp: span) {
|
||||
do option::iter (sp.expn_info) |ei| {
|
||||
let ss = option::map_default(ei.callie.span, @~"",
|
||||
do option::iter(&sp.expn_info) |ei| {
|
||||
let ss = option::map_default(&ei.callie.span, @~"",
|
||||
|span| @codemap::span_to_str(span, cm));
|
||||
print_diagnostic(*ss, note,
|
||||
fmt!("in expansion of #%s", ei.callie.name));
|
||||
|
@ -155,7 +155,7 @@ fn expand_ast(ecx: ext_ctxt, _sp: span,
|
||||
-> @ast::expr
|
||||
{
|
||||
let mut what = ~"expr";
|
||||
do option::iter(arg) |arg| {
|
||||
do arg.iter |arg| {
|
||||
let args: ~[@ast::expr] =
|
||||
match arg.node {
|
||||
ast::expr_vec(elts, _) => elts,
|
||||
@ -311,7 +311,7 @@ fn fold_crate(f: ast_fold, &&n: @ast::crate) -> @ast::crate {
|
||||
fn fold_expr(f: ast_fold, &&n: @ast::expr) -> @ast::expr {f.fold_expr(n)}
|
||||
fn fold_ty(f: ast_fold, &&n: @ast::ty) -> @ast::ty {f.fold_ty(n)}
|
||||
fn fold_item(f: ast_fold, &&n: @ast::item) -> @ast::item {
|
||||
option::get(f.fold_item(n)) //HACK: we know we don't drop items
|
||||
f.fold_item(n).get() //HACK: we know we don't drop items
|
||||
}
|
||||
fn fold_stmt(f: ast_fold, &&n: @ast::stmt) -> @ast::stmt {f.fold_stmt(n)}
|
||||
fn fold_pat(f: ast_fold, &&n: @ast::pat) -> @ast::pat {f.fold_pat(n)}
|
||||
|
@ -707,7 +707,7 @@ fn add_new_extension(cx: ext_ctxt, sp: span, arg: ast::mac_arg,
|
||||
None => cx.span_fatal(sp, ~"macro definition must have " +
|
||||
~"at least one clause")
|
||||
},
|
||||
ext: normal({expander: ext, span: Some(option::get(arg).span)})};
|
||||
ext: normal({expander: ext, span: Some(arg.get().span)})};
|
||||
|
||||
fn generic_extension(cx: ext_ctxt, sp: span, arg: ast::mac_arg,
|
||||
_body: ast::mac_body,
|
||||
|
@ -114,7 +114,7 @@ fn fold_mac_(m: mac, fld: ast_fold) -> mac {
|
||||
match m.node {
|
||||
mac_invoc(pth, arg, body) => {
|
||||
mac_invoc(fld.fold_path(pth),
|
||||
option::map(arg, |x| fld.fold_expr(x)), body)
|
||||
option::map(&arg, |x| fld.fold_expr(x)), body)
|
||||
}
|
||||
mac_invoc_tt(*) => m.node,
|
||||
mac_ellipsis => mac_ellipsis,
|
||||
@ -241,7 +241,7 @@ fn noop_fold_item_underscore(i: item_, fld: ast_fold) -> item_ {
|
||||
item_enum(ast::enum_def({
|
||||
variants: vec::map(enum_definition.variants,
|
||||
|x| fld.fold_variant(*x)),
|
||||
common: option::map(enum_definition.common,
|
||||
common: option::map(&enum_definition.common,
|
||||
|x| fold_struct_def(x, fld))
|
||||
}), fold_ty_params(typms, fld))
|
||||
}
|
||||
@ -286,7 +286,7 @@ fn fold_struct_def(struct_def: @ast::struct_def, fld: ast_fold)
|
||||
});
|
||||
}
|
||||
}
|
||||
let dtor = do option::map(struct_def.dtor) |dtor| {
|
||||
let dtor = do option::map(&struct_def.dtor) |dtor| {
|
||||
let dtor_body = fld.fold_block(dtor.node.body);
|
||||
let dtor_id = fld.new_id(dtor.node.id);
|
||||
{node: {body: dtor_body,
|
||||
@ -331,7 +331,7 @@ fn noop_fold_method(&&m: @method, fld: ast_fold) -> @method {
|
||||
fn noop_fold_block(b: blk_, fld: ast_fold) -> blk_ {
|
||||
return {view_items: vec::map(b.view_items, |x| fld.fold_view_item(*x)),
|
||||
stmts: vec::map(b.stmts, |x| fld.fold_stmt(*x)),
|
||||
expr: option::map(b.expr, |x| fld.fold_expr(x)),
|
||||
expr: option::map(&b.expr, |x| fld.fold_expr(x)),
|
||||
id: fld.new_id(b.id),
|
||||
rules: b.rules};
|
||||
}
|
||||
@ -346,7 +346,7 @@ fn noop_fold_stmt(s: stmt_, fld: ast_fold) -> stmt_ {
|
||||
|
||||
fn noop_fold_arm(a: arm, fld: ast_fold) -> arm {
|
||||
return {pats: vec::map(a.pats, |x| fld.fold_pat(*x)),
|
||||
guard: option::map(a.guard, |x| fld.fold_expr(x)),
|
||||
guard: option::map(&a.guard, |x| fld.fold_expr(x)),
|
||||
body: fld.fold_block(a.body)};
|
||||
}
|
||||
|
||||
@ -356,11 +356,11 @@ fn noop_fold_pat(p: pat_, fld: ast_fold) -> pat_ {
|
||||
pat_ident(binding_mode, pth, sub) => {
|
||||
pat_ident(binding_mode,
|
||||
fld.fold_path(pth),
|
||||
option::map(sub, |x| fld.fold_pat(x)))
|
||||
option::map(&sub, |x| fld.fold_pat(x)))
|
||||
}
|
||||
pat_lit(e) => pat_lit(fld.fold_expr(e)),
|
||||
pat_enum(pth, pats) => {
|
||||
pat_enum(fld.fold_path(pth), option::map(pats,
|
||||
pat_enum(fld.fold_path(pth), option::map(&pats,
|
||||
|pats| vec::map(pats, |x| fld.fold_pat(*x))))
|
||||
}
|
||||
pat_rec(fields, etc) => {
|
||||
@ -433,7 +433,7 @@ fn noop_fold_expr(e: expr_, fld: ast_fold) -> expr_ {
|
||||
expr_repeat(fld.fold_expr(expr), fld.fold_expr(count), mutt),
|
||||
expr_rec(fields, maybe_expr) => {
|
||||
expr_rec(vec::map(fields, |x| fold_field(*x)),
|
||||
option::map(maybe_expr, |x| fld.fold_expr(x)))
|
||||
option::map(&maybe_expr, |x| fld.fold_expr(x)))
|
||||
}
|
||||
expr_tup(elts) => expr_tup(vec::map(elts, |x| fld.fold_expr(*x))),
|
||||
expr_call(f, args, blk) => {
|
||||
@ -452,14 +452,14 @@ fn noop_fold_expr(e: expr_, fld: ast_fold) -> expr_ {
|
||||
expr_addr_of(m, ohs) => expr_addr_of(m, fld.fold_expr(ohs)),
|
||||
expr_if(cond, tr, fl) => {
|
||||
expr_if(fld.fold_expr(cond), fld.fold_block(tr),
|
||||
option::map(fl, |x| fld.fold_expr(x)))
|
||||
option::map(&fl, |x| fld.fold_expr(x)))
|
||||
}
|
||||
expr_while(cond, body) => {
|
||||
expr_while(fld.fold_expr(cond), fld.fold_block(body))
|
||||
}
|
||||
expr_loop(body, opt_ident) => {
|
||||
expr_loop(fld.fold_block(body),
|
||||
option::map(opt_ident, |x| fld.fold_ident(x)))
|
||||
option::map(&opt_ident, |x| fld.fold_ident(x)))
|
||||
}
|
||||
expr_match(expr, arms) => {
|
||||
expr_match(fld.fold_expr(expr),
|
||||
@ -501,12 +501,12 @@ fn noop_fold_expr(e: expr_, fld: ast_fold) -> expr_ {
|
||||
expr_index(fld.fold_expr(el), fld.fold_expr(er))
|
||||
}
|
||||
expr_path(pth) => expr_path(fld.fold_path(pth)),
|
||||
expr_fail(e) => expr_fail(option::map(e, |x| fld.fold_expr(x))),
|
||||
expr_fail(e) => expr_fail(option::map(&e, |x| fld.fold_expr(x))),
|
||||
expr_break(opt_ident) =>
|
||||
expr_break(option::map(opt_ident, |x| fld.fold_ident(x))),
|
||||
expr_break(option::map(&opt_ident, |x| fld.fold_ident(x))),
|
||||
expr_again(opt_ident) =>
|
||||
expr_again(option::map(opt_ident, |x| fld.fold_ident(x))),
|
||||
expr_ret(e) => expr_ret(option::map(e, |x| fld.fold_expr(x))),
|
||||
expr_again(option::map(&opt_ident, |x| fld.fold_ident(x))),
|
||||
expr_ret(e) => expr_ret(option::map(&e, |x| fld.fold_expr(x))),
|
||||
expr_log(i, lv, e) => expr_log(i, fld.fold_expr(lv),
|
||||
fld.fold_expr(e)),
|
||||
expr_assert(e) => expr_assert(fld.fold_expr(e)),
|
||||
@ -514,7 +514,7 @@ fn noop_fold_expr(e: expr_, fld: ast_fold) -> expr_ {
|
||||
expr_struct(path, fields, maybe_expr) => {
|
||||
expr_struct(fld.fold_path(path),
|
||||
vec::map(fields, |x| fold_field(*x)),
|
||||
option::map(maybe_expr, |x| fld.fold_expr(x)))
|
||||
option::map(&maybe_expr, |x| fld.fold_expr(x)))
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -573,7 +573,7 @@ fn noop_fold_variant(v: variant_, fld: ast_fold) -> variant_ {
|
||||
kind = tuple_variant_kind(vec::map(variant_args,
|
||||
|x| fold_variant_arg(*x))),
|
||||
struct_variant_kind(struct_def) => {
|
||||
let dtor = do option::map(struct_def.dtor) |dtor| {
|
||||
let dtor = do option::map(&struct_def.dtor) |dtor| {
|
||||
let dtor_body = fld.fold_block(dtor.node.body);
|
||||
let dtor_id = fld.new_id(dtor.node.id);
|
||||
{node: {body: dtor_body,
|
||||
@ -593,7 +593,7 @@ fn noop_fold_variant(v: variant_, fld: ast_fold) -> variant_ {
|
||||
enum_variant_kind(enum_definition) => {
|
||||
let variants = vec::map(enum_definition.variants,
|
||||
|x| fld.fold_variant(*x));
|
||||
let common = option::map(enum_definition.common,
|
||||
let common = option::map(&enum_definition.common,
|
||||
|x| fold_struct_def(x, fld));
|
||||
kind = enum_variant_kind(ast::enum_def({ variants: variants,
|
||||
common: common }));
|
||||
|
@ -73,7 +73,7 @@ fn parse_crate_from_crate_file(input: &Path, cfg: ast::crate_cfg,
|
||||
sess.chpos = rdr.chpos;
|
||||
sess.byte_pos = sess.byte_pos + rdr.pos;
|
||||
let cx = @{sess: sess, cfg: /* FIXME (#2543) */ copy p.cfg};
|
||||
let companionmod = option::map(input.filestem(), |s| Path(s));
|
||||
let companionmod = input.filestem().map(|s| Path(s));
|
||||
let (m, attrs) = eval::eval_crate_directives_to_mod(
|
||||
cx, cdirs, &prefix, &companionmod);
|
||||
let mut hi = p.span.hi;
|
||||
|
@ -364,7 +364,7 @@ fn scan_number(c: char, rdr: string_reader) -> token::token {
|
||||
if str::len(num_str) == 0u {
|
||||
rdr.fatal(~"no valid digits found for number");
|
||||
}
|
||||
let parsed = option::get(u64::from_str_radix(num_str, base as u64));
|
||||
let parsed = u64::from_str_radix(num_str, base as u64).get();
|
||||
match tp {
|
||||
either::Left(t) => return token::LIT_INT(parsed as i64, t),
|
||||
either::Right(t) => return token::LIT_UINT(parsed, t)
|
||||
@ -412,7 +412,7 @@ fn scan_number(c: char, rdr: string_reader) -> token::token {
|
||||
if str::len(num_str) == 0u {
|
||||
rdr.fatal(~"no valid digits found for number");
|
||||
}
|
||||
let parsed = option::get(u64::from_str_radix(num_str, base as u64));
|
||||
let parsed = u64::from_str_radix(num_str, base as u64).get();
|
||||
|
||||
debug!("lexing %s as an unsuffixed integer literal",
|
||||
num_str);
|
||||
|
@ -2743,7 +2743,7 @@ impl parser {
|
||||
token_to_str(self.reader, self.token)));
|
||||
}
|
||||
|
||||
let actual_dtor = do option::map(the_dtor) |dtor| {
|
||||
let actual_dtor = do the_dtor.map |dtor| {
|
||||
let (d_body, d_attrs, d_s) = dtor;
|
||||
{node: {id: self.get_id(),
|
||||
attrs: d_attrs,
|
||||
@ -3111,7 +3111,7 @@ impl parser {
|
||||
}
|
||||
}
|
||||
self.bump();
|
||||
let mut actual_dtor = do option::map(the_dtor) |dtor| {
|
||||
let mut actual_dtor = do the_dtor.map |dtor| {
|
||||
let (d_body, d_attrs, d_s) = dtor;
|
||||
{node: {id: self.get_id(),
|
||||
attrs: d_attrs,
|
||||
|
@ -652,7 +652,7 @@ fn print_struct(s: ps, struct_def: @ast::struct_def, tps: ~[ast::ty_param],
|
||||
}
|
||||
bopen(s);
|
||||
hardbreak_if_not_bol(s);
|
||||
do option::iter(struct_def.ctor) |ctor| {
|
||||
do struct_def.ctor.iter |ctor| {
|
||||
maybe_print_comment(s, ctor.span.lo);
|
||||
print_outer_attributes(s, ctor.node.attrs);
|
||||
// Doesn't call head because there shouldn't be a space after new.
|
||||
@ -664,7 +664,7 @@ fn print_struct(s: ps, struct_def: @ast::struct_def, tps: ~[ast::ty_param],
|
||||
space(s.s);
|
||||
print_block(s, ctor.node.body);
|
||||
}
|
||||
do option::iter(struct_def.dtor) |dtor| {
|
||||
do struct_def.dtor.iter |dtor| {
|
||||
hardbreak_if_not_bol(s);
|
||||
maybe_print_comment(s, dtor.span.lo);
|
||||
print_outer_attributes(s, dtor.node.attrs);
|
||||
@ -979,7 +979,7 @@ fn print_mac(s: ps, m: ast::mac) {
|
||||
Some(@{node: ast::expr_vec(_, _), _}) => (),
|
||||
_ => word(s.s, ~" ")
|
||||
}
|
||||
option::iter(arg, |a| print_expr(s, a));
|
||||
arg.iter(|a| print_expr(s, a));
|
||||
// FIXME: extension 'body' (#2339)
|
||||
}
|
||||
ast::mac_invoc_tt(pth, tts) => {
|
||||
@ -1177,7 +1177,7 @@ fn print_expr(s: ps, &&expr: @ast::expr) {
|
||||
ast::expr_loop(blk, opt_ident) => {
|
||||
head(s, ~"loop");
|
||||
space(s.s);
|
||||
option::iter(opt_ident, |ident| {print_ident(s, ident); space(s.s)});
|
||||
opt_ident.iter(|ident| {print_ident(s, ident); space(s.s)});
|
||||
print_block(s, blk);
|
||||
}
|
||||
ast::expr_match(expr, arms) => {
|
||||
@ -1360,12 +1360,12 @@ fn print_expr(s: ps, &&expr: @ast::expr) {
|
||||
ast::expr_break(opt_ident) => {
|
||||
word(s.s, ~"break");
|
||||
space(s.s);
|
||||
option::iter(opt_ident, |ident| {print_ident(s, ident); space(s.s)});
|
||||
opt_ident.iter(|ident| {print_ident(s, ident); space(s.s)});
|
||||
}
|
||||
ast::expr_again(opt_ident) => {
|
||||
word(s.s, ~"loop");
|
||||
space(s.s);
|
||||
option::iter(opt_ident, |ident| {print_ident(s, ident); space(s.s)});
|
||||
opt_ident.iter(|ident| {print_ident(s, ident); space(s.s)});
|
||||
}
|
||||
ast::expr_ret(result) => {
|
||||
word(s.s, ~"return");
|
||||
@ -1920,7 +1920,7 @@ fn maybe_print_trailing_comment(s: ps, span: codemap::span,
|
||||
fn print_remaining_comments(s: ps) {
|
||||
// If there aren't any remaining comments, then we need to manually
|
||||
// make sure there is a line break at the end.
|
||||
if option::is_none(next_comment(s)) { hardbreak(s.s); }
|
||||
if next_comment(s).is_none() { hardbreak(s.s); }
|
||||
loop {
|
||||
match next_comment(s) {
|
||||
Some(cmnt) => { print_comment(s, cmnt); s.cur_cmnt += 1u; }
|
||||
|
@ -222,7 +222,7 @@ fn visit_pat<E>(p: @pat, e: E, v: vt<E>) {
|
||||
match p.node {
|
||||
pat_enum(path, children) => {
|
||||
visit_path(path, e, v);
|
||||
do option::iter(children) |children| {
|
||||
do option::iter(&children) |children| {
|
||||
for children.each |child| { v.visit_pat(*child, e, v); }}
|
||||
}
|
||||
pat_rec(fields, _) => for fields.each |f| {
|
||||
@ -241,7 +241,7 @@ fn visit_pat<E>(p: @pat, e: E, v: vt<E>) {
|
||||
v.visit_pat(inner, e, v),
|
||||
pat_ident(_, path, inner) => {
|
||||
visit_path(path, e, v);
|
||||
do option::iter(inner) |subpat| { v.visit_pat(subpat, e, v)};
|
||||
do option::iter(&inner) |subpat| { v.visit_pat(subpat, e, v)};
|
||||
}
|
||||
pat_lit(ex) => v.visit_expr(ex, e, v),
|
||||
pat_range(e1, e2) => { v.visit_expr(e1, e, v); v.visit_expr(e2, e, v); }
|
||||
@ -341,10 +341,10 @@ fn visit_struct_def<E>(sd: @struct_def, nm: ast::ident, tps: ~[ty_param],
|
||||
for sd.traits.each |p| {
|
||||
visit_path(p.path, e, v);
|
||||
}
|
||||
do option::iter(sd.ctor) |ctor| {
|
||||
do option::iter(&sd.ctor) |ctor| {
|
||||
visit_class_ctor_helper(ctor, nm, tps, ast_util::local_def(id), e, v);
|
||||
};
|
||||
do option::iter(sd.dtor) |dtor| {
|
||||
do option::iter(&sd.dtor) |dtor| {
|
||||
visit_class_dtor_helper(dtor, tps, ast_util::local_def(id), e, v)
|
||||
};
|
||||
}
|
||||
@ -395,7 +395,7 @@ fn visit_exprs<E>(exprs: ~[@expr], e: E, v: vt<E>) {
|
||||
fn visit_mac<E>(m: mac, e: E, v: vt<E>) {
|
||||
match m.node {
|
||||
ast::mac_invoc(_, arg, _) => {
|
||||
option::map(arg, |arg| v.visit_expr(arg, e, v)); }
|
||||
option::map(&arg, |arg| v.visit_expr(arg, e, v)); }
|
||||
ast::mac_invoc_tt(*) => { /* no user-serviceable parts inside */ }
|
||||
ast::mac_ellipsis => (),
|
||||
ast::mac_aq(*) => { /* FIXME: maybe visit (Issue #2340) */ }
|
||||
|
@ -688,7 +688,7 @@ fn link_binary(sess: session,
|
||||
}
|
||||
let dir = cratepath.dirname();
|
||||
if dir != ~"" { vec::push(cc_args, ~"-L" + dir); }
|
||||
let libarg = unlib(sess.targ_cfg, option::get(cratepath.filestem()));
|
||||
let libarg = unlib(sess.targ_cfg, cratepath.filestem().get());
|
||||
vec::push(cc_args, ~"-l" + libarg);
|
||||
}
|
||||
|
||||
@ -717,7 +717,7 @@ fn link_binary(sess: session,
|
||||
// be rpathed
|
||||
if sess.targ_cfg.os == session::os_macos {
|
||||
vec::push(cc_args, ~"-Wl,-install_name,@rpath/"
|
||||
+ option::get(output.filename()));
|
||||
+ output.filename().get());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -254,7 +254,7 @@ fn compile_upto(sess: session, cfg: ast::crate_cfg,
|
||||
time(time_passes, ~"lint checking", || lint::check_crate(ty_cx, crate));
|
||||
|
||||
if upto == cu_no_trans { return {crate: crate, tcx: Some(ty_cx)}; }
|
||||
let outputs = option::get(outputs);
|
||||
let outputs = outputs.get();
|
||||
|
||||
let maps = {mutbl_map: mutbl_map,
|
||||
root_map: root_map,
|
||||
@ -353,7 +353,7 @@ fn pretty_print_input(sess: session, cfg: ast::crate_cfg, input: input,
|
||||
let ann = match ppm {
|
||||
ppm_typed => {
|
||||
{pre: ann_paren_for_expr,
|
||||
post: |a| ann_typed_post(option::get(tcx), a) }
|
||||
post: |a| ann_typed_post(tcx.get(), a) }
|
||||
}
|
||||
ppm_identified | ppm_expanded_identified => {
|
||||
{pre: ann_paren_for_expr, post: ann_identified_post}
|
||||
@ -516,7 +516,7 @@ fn build_session_options(binary: ~str,
|
||||
let extra_debuginfo = opt_present(matches, ~"xg");
|
||||
let debuginfo = opt_present(matches, ~"g") || extra_debuginfo;
|
||||
let sysroot_opt = getopts::opt_maybe_str(matches, ~"sysroot");
|
||||
let sysroot_opt = option::map(sysroot_opt, |m| Path(m));
|
||||
let sysroot_opt = sysroot_opt.map(|m| Path(m));
|
||||
let target_opt = getopts::opt_maybe_str(matches, ~"target");
|
||||
let save_temps = getopts::opt_present(matches, ~"save-temps");
|
||||
match output_type {
|
||||
@ -695,7 +695,7 @@ fn build_output_filenames(input: input,
|
||||
};
|
||||
|
||||
let stem = match input {
|
||||
file_input(ifile) => option::get(ifile.filestem()),
|
||||
file_input(ifile) => ifile.filestem().get(),
|
||||
str_input(_) => ~"rust_out"
|
||||
};
|
||||
|
||||
|
@ -171,12 +171,12 @@ fn run_compiler(args: ~[~str], demitter: diagnostic::emitter) {
|
||||
let sopts = build_session_options(binary, matches, demitter);
|
||||
let sess = build_session(sopts, demitter);
|
||||
let odir = getopts::opt_maybe_str(matches, ~"out-dir");
|
||||
let odir = option::map(odir, |o| Path(o));
|
||||
let odir = odir.map(|o| Path(o));
|
||||
let ofile = getopts::opt_maybe_str(matches, ~"o");
|
||||
let ofile = option::map(ofile, |o| Path(o));
|
||||
let ofile = ofile.map(|o| Path(o));
|
||||
let cfg = build_configuration(sess, binary, input);
|
||||
let pretty =
|
||||
option::map(getopts::opt_default(matches, ~"pretty",
|
||||
option::map(&getopts::opt_default(matches, ~"pretty",
|
||||
~"normal"),
|
||||
|a| parse_pretty(sess, a) );
|
||||
match pretty {
|
||||
|
@ -104,7 +104,7 @@ fn fold_block(cx: ctxt, b: ast::blk_, fld: fold::ast_fold) ->
|
||||
let filtered_stmts = vec::filter_map(b.stmts, filter);
|
||||
return {view_items: b.view_items,
|
||||
stmts: vec::map(filtered_stmts, |x| fld.fold_stmt(*x)),
|
||||
expr: option::map(b.expr, |x| fld.fold_expr(x)),
|
||||
expr: option::map(&b.expr, |x| fld.fold_expr(x)),
|
||||
id: b.id,
|
||||
rules: b.rules};
|
||||
}
|
||||
|
@ -176,7 +176,7 @@ fn get_dep_hashes(cstore: cstore) -> ~[~str] {
|
||||
}
|
||||
|
||||
fn get_path(cstore: cstore, d: ast::def_id) -> ~[~str] {
|
||||
option::map_default(p(cstore).mod_path_map.find(d), ~[],
|
||||
option::map_default(&p(cstore).mod_path_map.find(d), ~[],
|
||||
|ds| str::split_str(*ds, ~"::"))
|
||||
}
|
||||
// Local Variables:
|
||||
|
@ -92,7 +92,7 @@ fn maybe_find_item(item_id: int, items: ebml::Doc) -> Option<ebml::Doc> {
|
||||
}
|
||||
|
||||
fn find_item(item_id: int, items: ebml::Doc) -> ebml::Doc {
|
||||
return option::get(maybe_find_item(item_id, items));
|
||||
return maybe_find_item(item_id, items).get();
|
||||
}
|
||||
|
||||
// Looks up an item in the given metadata and returns an ebml doc pointing
|
||||
@ -202,7 +202,7 @@ fn each_reexport(d: ebml::Doc, f: fn(ebml::Doc) -> bool) {
|
||||
fn field_mutability(d: ebml::Doc) -> ast::class_mutability {
|
||||
// Use maybe_get_doc in case it's a method
|
||||
option::map_default(
|
||||
ebml::maybe_get_doc(d, tag_class_mut),
|
||||
&ebml::maybe_get_doc(d, tag_class_mut),
|
||||
ast::class_immutable,
|
||||
|d| {
|
||||
match ebml::doc_as_u8(d) as char {
|
||||
@ -213,7 +213,7 @@ fn field_mutability(d: ebml::Doc) -> ast::class_mutability {
|
||||
}
|
||||
|
||||
fn variant_disr_val(d: ebml::Doc) -> Option<int> {
|
||||
do option::chain(ebml::maybe_get_doc(d, tag_disr_val)) |val_doc| {
|
||||
do option::chain(&ebml::maybe_get_doc(d, tag_disr_val)) |val_doc| {
|
||||
int::parse_bytes(ebml::doc_data(val_doc), 10u)
|
||||
}
|
||||
}
|
||||
@ -384,7 +384,7 @@ fn get_impl_method(intr: ident_interner, cdata: cmd, id: ast::node_id,
|
||||
found = Some(translate_def_id(cdata, m_did));
|
||||
}
|
||||
}
|
||||
option::get(found)
|
||||
found.get()
|
||||
}
|
||||
|
||||
fn get_class_method(intr: ident_interner, cdata: cmd, id: ast::node_id,
|
||||
|
@ -602,7 +602,7 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::Writer, item: @item,
|
||||
struct_def.fields, struct_def.methods,
|
||||
index);
|
||||
/* Encode the dtor */
|
||||
do option::iter(struct_def.dtor) |dtor| {
|
||||
do struct_def.dtor.iter |dtor| {
|
||||
vec::push(*index, {val: dtor.node.id, pos: ebml_w.writer.tell()});
|
||||
encode_info_for_ctor(ecx, ebml_w, dtor.node.id,
|
||||
ecx.tcx.sess.ident_of(
|
||||
@ -635,7 +635,7 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::Writer, item: @item,
|
||||
}
|
||||
/* Encode the dtor */
|
||||
/* Encode id for dtor */
|
||||
do option::iter(struct_def.dtor) |dtor| {
|
||||
do struct_def.dtor.iter |dtor| {
|
||||
do ebml_w.wr_tag(tag_item_dtor) {
|
||||
encode_def_id(ebml_w, local_def(dtor.node.id));
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ fn search<T: Copy>(filesearch: filesearch, pick: pick<T>) -> Option<T> {
|
||||
for os::list_dir_path(lib_search_path).each |path| {
|
||||
debug!("testing %s", path.to_str());
|
||||
let maybe_picked = pick(*path);
|
||||
if option::is_some(maybe_picked) {
|
||||
if maybe_picked.is_some() {
|
||||
debug!("picked %s", path.to_str());
|
||||
rslt = maybe_picked;
|
||||
break;
|
||||
@ -82,7 +82,7 @@ fn search<T: Copy>(filesearch: filesearch, pick: pick<T>) -> Option<T> {
|
||||
debug!("rejected %s", path.to_str());
|
||||
}
|
||||
}
|
||||
if option::is_some(rslt) { break; }
|
||||
if rslt.is_some() { break; }
|
||||
}
|
||||
return rslt;
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ fn find_library_crate_aux(cx: ctxt,
|
||||
let mut matches = ~[];
|
||||
filesearch::search(filesearch, |path| {
|
||||
debug!("inspecting file %s", path.to_str());
|
||||
let f: ~str = option::get(path.filename());
|
||||
let f: ~str = path.filename().get();
|
||||
if !(str::starts_with(f, prefix) && str::ends_with(f, suffix)) {
|
||||
debug!("skipping %s, doesn't look like %s*%s", path.to_str(),
|
||||
prefix, suffix);
|
||||
|
@ -719,7 +719,7 @@ fn encode_side_tables_for_id(ecx: @e::encode_ctxt,
|
||||
|
||||
debug!("Encoding side tables for id %d", id);
|
||||
|
||||
do option::iter(tcx.def_map.find(id)) |def| {
|
||||
do option::iter(&tcx.def_map.find(id)) |def| {
|
||||
do ebml_w.tag(c::tag_table_def) {
|
||||
ebml_w.id(id);
|
||||
do ebml_w.tag(c::tag_table_val) {
|
||||
@ -727,7 +727,7 @@ fn encode_side_tables_for_id(ecx: @e::encode_ctxt,
|
||||
}
|
||||
}
|
||||
}
|
||||
do option::iter((*tcx.node_types).find(id as uint)) |ty| {
|
||||
do option::iter(&(*tcx.node_types).find(id as uint)) |ty| {
|
||||
do ebml_w.tag(c::tag_table_node_type) {
|
||||
ebml_w.id(id);
|
||||
do ebml_w.tag(c::tag_table_val) {
|
||||
@ -736,7 +736,7 @@ fn encode_side_tables_for_id(ecx: @e::encode_ctxt,
|
||||
}
|
||||
}
|
||||
|
||||
do option::iter(tcx.node_type_substs.find(id)) |tys| {
|
||||
do option::iter(&tcx.node_type_substs.find(id)) |tys| {
|
||||
do ebml_w.tag(c::tag_table_node_type_subst) {
|
||||
ebml_w.id(id);
|
||||
do ebml_w.tag(c::tag_table_val) {
|
||||
@ -745,7 +745,7 @@ fn encode_side_tables_for_id(ecx: @e::encode_ctxt,
|
||||
}
|
||||
}
|
||||
|
||||
do option::iter(tcx.freevars.find(id)) |fv| {
|
||||
do option::iter(&tcx.freevars.find(id)) |fv| {
|
||||
do ebml_w.tag(c::tag_table_freevars) {
|
||||
ebml_w.id(id);
|
||||
do ebml_w.tag(c::tag_table_val) {
|
||||
@ -757,7 +757,7 @@ fn encode_side_tables_for_id(ecx: @e::encode_ctxt,
|
||||
}
|
||||
|
||||
let lid = {crate: ast::local_crate, node: id};
|
||||
do option::iter(tcx.tcache.find(lid)) |tpbt| {
|
||||
do option::iter(&tcx.tcache.find(lid)) |tpbt| {
|
||||
do ebml_w.tag(c::tag_table_tcache) {
|
||||
ebml_w.id(id);
|
||||
do ebml_w.tag(c::tag_table_val) {
|
||||
@ -766,7 +766,7 @@ fn encode_side_tables_for_id(ecx: @e::encode_ctxt,
|
||||
}
|
||||
}
|
||||
|
||||
do option::iter(tcx.ty_param_bounds.find(id)) |pbs| {
|
||||
do option::iter(&tcx.ty_param_bounds.find(id)) |pbs| {
|
||||
do ebml_w.tag(c::tag_table_param_bounds) {
|
||||
ebml_w.id(id);
|
||||
do ebml_w.tag(c::tag_table_val) {
|
||||
@ -789,13 +789,13 @@ fn encode_side_tables_for_id(ecx: @e::encode_ctxt,
|
||||
// }
|
||||
//}
|
||||
|
||||
do option::iter(maps.mutbl_map.find(id)) |_m| {
|
||||
do option::iter(&maps.mutbl_map.find(id)) |_m| {
|
||||
do ebml_w.tag(c::tag_table_mutbl) {
|
||||
ebml_w.id(id);
|
||||
}
|
||||
}
|
||||
|
||||
do option::iter(maps.last_use_map.find(id)) |m| {
|
||||
do option::iter(&maps.last_use_map.find(id)) |m| {
|
||||
do ebml_w.tag(c::tag_table_last_use) {
|
||||
ebml_w.id(id);
|
||||
do ebml_w.tag(c::tag_table_val) {
|
||||
@ -806,7 +806,7 @@ fn encode_side_tables_for_id(ecx: @e::encode_ctxt,
|
||||
}
|
||||
}
|
||||
|
||||
do option::iter(maps.method_map.find(id)) |mme| {
|
||||
do option::iter(&maps.method_map.find(id)) |mme| {
|
||||
do ebml_w.tag(c::tag_table_method_map) {
|
||||
ebml_w.id(id);
|
||||
do ebml_w.tag(c::tag_table_val) {
|
||||
@ -815,7 +815,7 @@ fn encode_side_tables_for_id(ecx: @e::encode_ctxt,
|
||||
}
|
||||
}
|
||||
|
||||
do option::iter(maps.vtable_map.find(id)) |dr| {
|
||||
do option::iter(&maps.vtable_map.find(id)) |dr| {
|
||||
do ebml_w.tag(c::tag_table_vtable_map) {
|
||||
ebml_w.id(id);
|
||||
do ebml_w.tag(c::tag_table_val) {
|
||||
@ -824,7 +824,7 @@ fn encode_side_tables_for_id(ecx: @e::encode_ctxt,
|
||||
}
|
||||
}
|
||||
|
||||
do option::iter(tcx.adjustments.find(id)) |adj| {
|
||||
do option::iter(&tcx.adjustments.find(id)) |adj| {
|
||||
do ebml_w.tag(c::tag_table_adjustments) {
|
||||
ebml_w.id(id);
|
||||
do ebml_w.tag(c::tag_table_val) {
|
||||
|
@ -67,7 +67,7 @@ fn check_arms(tcx: ty::ctxt, arms: ~[arm]) {
|
||||
}
|
||||
_ => ()
|
||||
}
|
||||
if option::is_none(arm.guard) { vec::push(seen, v); }
|
||||
if arm.guard.is_none() { vec::push(seen, v); }
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -233,7 +233,7 @@ fn is_useful_specialized(tcx: ty::ctxt, m: matrix, v: ~[@pat], ctor: ctor,
|
||||
arity: uint, lty: ty::t) -> useful {
|
||||
let ms = vec::filter_map(m, |r| specialize(tcx, r, ctor, arity, lty) );
|
||||
let could_be_useful = is_useful(
|
||||
tcx, ms, option::get(specialize(tcx, v, ctor, arity, lty)));
|
||||
tcx, ms, specialize(tcx, v, ctor, arity, lty).get());
|
||||
match could_be_useful {
|
||||
useful_ => useful(lty, ctor),
|
||||
u => u
|
||||
@ -287,7 +287,7 @@ fn missing_ctor(tcx: ty::ctxt, m: matrix, left_ty: ty::t) -> Option<ctor> {
|
||||
ty::ty_enum(eid, _) => {
|
||||
let mut found = ~[];
|
||||
for m.each |r| {
|
||||
do option::iter(pat_ctor_id(tcx, r[0])) |id| {
|
||||
do option::iter(&pat_ctor_id(tcx, r[0])) |id| {
|
||||
if !vec::contains(found, id) { vec::push(found, id); }
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ fn check_item(sess: session, ast_map: ast_map::map,
|
||||
}
|
||||
item_enum(enum_definition, _) => {
|
||||
for enum_definition.variants.each |var| {
|
||||
do option::iter(var.node.disr_expr) |ex| {
|
||||
do option::iter(&var.node.disr_expr) |ex| {
|
||||
v.visit_expr(ex, true, v);
|
||||
}
|
||||
}
|
||||
|
@ -375,7 +375,7 @@ fn lit_to_const(lit: @lit) -> const_val {
|
||||
lit_int(n, _) => const_int(n),
|
||||
lit_uint(n, _) => const_uint(n),
|
||||
lit_int_unsuffixed(n) => const_int(n),
|
||||
lit_float(n, _) => const_float(option::get(float::from_str(*n)) as f64),
|
||||
lit_float(n, _) => const_float(float::from_str(*n).get() as f64),
|
||||
lit_nil => const_int(0i64),
|
||||
lit_bool(b) => const_bool(b)
|
||||
}
|
||||
|
@ -248,7 +248,7 @@ fn check_expr(e: @expr, cx: ctx, v: visit::vt<ctx>) {
|
||||
};
|
||||
|
||||
// Handle any kind bounds on type parameters
|
||||
do option::iter(cx.tcx.node_type_substs.find(id_to_use)) |ts| {
|
||||
do option::iter(&cx.tcx.node_type_substs.find(id_to_use)) |ts| {
|
||||
let bounds = match e.node {
|
||||
expr_path(_) => {
|
||||
let did = ast_util::def_id_of_def(cx.tcx.def_map.get(e.id));
|
||||
@ -373,7 +373,7 @@ fn check_stmt(stmt: @stmt, cx: ctx, v: visit::vt<ctx>) {
|
||||
fn check_ty(aty: @ty, cx: ctx, v: visit::vt<ctx>) {
|
||||
match aty.node {
|
||||
ty_path(_, id) => {
|
||||
do option::iter(cx.tcx.node_type_substs.find(id)) |ts| {
|
||||
do option::iter(&cx.tcx.node_type_substs.find(id)) |ts| {
|
||||
let did = ast_util::def_id_of_def(cx.tcx.def_map.get(id));
|
||||
let bounds = ty::lookup_item_type(cx.tcx, did).bounds;
|
||||
do vec::iter2(ts, *bounds) |ty, bound| {
|
||||
|
@ -1168,7 +1168,7 @@ impl Resolver {
|
||||
|
||||
// Record the def ID of this struct.
|
||||
self.structs.insert(local_def(item.id),
|
||||
is_some(struct_definition.ctor));
|
||||
struct_definition.ctor.is_some());
|
||||
|
||||
visit_item(item, new_parent, visitor);
|
||||
}
|
||||
@ -1607,7 +1607,7 @@ impl Resolver {
|
||||
let modules = HashMap();
|
||||
|
||||
// Create all the items reachable by paths.
|
||||
for each_path(self.session.cstore, get(root.def_id).crate)
|
||||
for each_path(self.session.cstore, root.def_id.get().crate)
|
||||
|path_entry| {
|
||||
|
||||
debug!("(building reduced graph for external crate) found path \
|
||||
|
@ -354,7 +354,7 @@ fn enter_opt(bcx: block, m: &[@Match/&r], opt: &Opt, col: uint,
|
||||
match p.node {
|
||||
ast::pat_enum(_, subpats) => {
|
||||
if opt_eq(tcx, &variant_opt(tcx, p.id), opt) {
|
||||
Some(option::get_default(subpats,
|
||||
Some(option::get_default(&subpats,
|
||||
vec::from_elem(variant_size,
|
||||
dummy)))
|
||||
} else {
|
||||
@ -872,12 +872,12 @@ fn compile_submatch(bcx: block,
|
||||
/*
|
||||
For an empty match, a fall-through case must exist
|
||||
*/
|
||||
assert(m.len() > 0u || is_some(chk));
|
||||
assert(m.len() > 0u || chk.is_some());
|
||||
let _icx = bcx.insn_ctxt("alt::compile_submatch");
|
||||
let mut bcx = bcx;
|
||||
let tcx = bcx.tcx(), dm = tcx.def_map;
|
||||
if m.len() == 0u {
|
||||
Br(bcx, option::get(chk)());
|
||||
Br(bcx, chk.get()());
|
||||
return;
|
||||
}
|
||||
if m[0].pats.len() == 0u {
|
||||
@ -1019,7 +1019,7 @@ fn compile_submatch(bcx: block,
|
||||
};
|
||||
|
||||
let defaults = enter_default(else_cx, dm, m, col, val);
|
||||
let exhaustive = option::is_none(chk) && defaults.len() == 0u;
|
||||
let exhaustive = chk.is_none() && defaults.len() == 0u;
|
||||
let len = opts.len();
|
||||
let mut i = 0u;
|
||||
|
||||
|
@ -777,7 +777,7 @@ fn in_lpad_scope_cx(bcx: block, f: fn(scope_info)) {
|
||||
loop {
|
||||
match bcx.kind {
|
||||
block_scope(inf) => {
|
||||
if inf.cleanups.len() > 0u || is_none(bcx.parent) {
|
||||
if inf.cleanups.len() > 0u || bcx.parent.is_none() {
|
||||
f(inf); return;
|
||||
}
|
||||
}
|
||||
@ -1042,7 +1042,7 @@ fn new_block(cx: fn_ctxt, parent: Option<block>, +kind: block_kind,
|
||||
llvm::LLVMAppendBasicBlock(cx.llfn, buf)
|
||||
});
|
||||
let bcx = mk_block(llbb, parent, move kind, is_lpad, opt_node_info, cx);
|
||||
do option::iter(parent) |cx| {
|
||||
do option::iter(&parent) |cx| {
|
||||
if cx.unreachable { Unreachable(bcx); }
|
||||
};
|
||||
return bcx;
|
||||
@ -1164,12 +1164,12 @@ fn cleanup_and_leave(bcx: block, upto: Option<BasicBlockRef>,
|
||||
}
|
||||
cur = match cur.parent {
|
||||
Some(next) => next,
|
||||
None => { assert is_none(upto); break; }
|
||||
None => { assert upto.is_none(); break; }
|
||||
};
|
||||
}
|
||||
match leave {
|
||||
Some(target) => Br(bcx, target),
|
||||
None => { Resume(bcx, Load(bcx, option::get(bcx.fcx.personality))); }
|
||||
None => { Resume(bcx, Load(bcx, bcx.fcx.personality.get())); }
|
||||
}
|
||||
}
|
||||
|
||||
@ -1251,7 +1251,7 @@ fn alloc_local(cx: block, local: @ast::local) -> block {
|
||||
};
|
||||
let val = alloc_ty(cx, t);
|
||||
if cx.sess().opts.debuginfo {
|
||||
do option::iter(simple_name) |name| {
|
||||
do option::iter(&simple_name) |name| {
|
||||
str::as_c_str(cx.ccx().sess.str_of(name), |buf| {
|
||||
llvm::LLVMSetValueName(val, buf)
|
||||
});
|
||||
@ -1601,7 +1601,7 @@ fn trans_closure(ccx: @crate_ctxt, path: path, decl: ast::fn_decl,
|
||||
/* avoids the need for special cases to assign a type to
|
||||
the constructor body (since it has no explicit return) */
|
||||
&&
|
||||
(option::is_none(body.node.expr) ||
|
||||
(body.node.expr.is_none() ||
|
||||
ty::type_is_bot(block_ty) ||
|
||||
ty::type_is_nil(block_ty)) {
|
||||
bcx = controlflow::trans_block(bcx, body, expr::Ignore);
|
||||
@ -1728,7 +1728,7 @@ fn trans_class_ctor(ccx: @crate_ctxt, path: path, decl: ast::fn_decl,
|
||||
let selfdatum = datum::scratch_datum(bcx_top, rslt_ty, true);
|
||||
|
||||
// Initialize dtor flag (if any) to 1
|
||||
if option::is_some(ty::ty_dtor(bcx_top.tcx(), parent_id)) {
|
||||
if ty::ty_dtor(bcx_top.tcx(), parent_id).is_some() {
|
||||
let flag = GEPi(bcx_top, selfdatum.val, [0, 1]);
|
||||
Store(bcx_top, C_u8(1), flag);
|
||||
}
|
||||
@ -1761,7 +1761,7 @@ fn trans_class_dtor(ccx: @crate_ctxt, path: path,
|
||||
/* Look up the parent class's def_id */
|
||||
let mut class_ty = ty::lookup_item_type(tcx, parent_id).ty;
|
||||
/* Substitute in the class type if necessary */
|
||||
do option::iter(psubsts) |ss| {
|
||||
do option::iter(&psubsts) |ss| {
|
||||
class_ty = ty::subst_tps(tcx, ss.tys, class_ty);
|
||||
}
|
||||
|
||||
@ -1779,7 +1779,7 @@ fn trans_class_dtor(ccx: @crate_ctxt, path: path,
|
||||
|
||||
/* If we're monomorphizing, register the monomorphized decl
|
||||
for the dtor */
|
||||
do option::iter(hash_id) |h_id| {
|
||||
do option::iter(&hash_id) |h_id| {
|
||||
ccx.monomorphized.insert(h_id, lldecl);
|
||||
}
|
||||
/* Translate the dtor body */
|
||||
@ -1889,12 +1889,12 @@ fn trans_struct_def(ccx: @crate_ctxt, struct_def: @ast::struct_def,
|
||||
let psubsts = {tys: ty::ty_params_to_tys(ccx.tcx, tps),
|
||||
vtables: None,
|
||||
bounds: @~[]};
|
||||
do option::iter(struct_def.ctor) |ctor| {
|
||||
do option::iter(&struct_def.ctor) |ctor| {
|
||||
trans_class_ctor(ccx, *path, ctor.node.dec, ctor.node.body,
|
||||
get_item_val(ccx, ctor.node.id), psubsts,
|
||||
ctor.node.id, local_def(id), ctor.span);
|
||||
}
|
||||
do option::iter(struct_def.dtor) |dtor| {
|
||||
do option::iter(&struct_def.dtor) |dtor| {
|
||||
trans_class_dtor(ccx, *path, dtor.node.body,
|
||||
dtor.node.id, None, None, local_def(id));
|
||||
};
|
||||
@ -2070,7 +2070,7 @@ fn get_dtor_symbol(ccx: @crate_ctxt, path: path, id: ast::node_id,
|
||||
let t = ty::node_id_to_type(ccx.tcx, id);
|
||||
match ccx.item_symbols.find(id) {
|
||||
Some(s) => s,
|
||||
None if is_none(substs) => {
|
||||
None if substs.is_none() => {
|
||||
let s = mangle_exported_name(
|
||||
ccx,
|
||||
vec::append(path, ~[path_name(ccx.names(~"dtor"))]),
|
||||
|
@ -394,8 +394,8 @@ fn trans_call_inner(
|
||||
if ty::type_is_bot(ret_ty) {
|
||||
Unreachable(bcx);
|
||||
} else if ret_in_loop {
|
||||
bcx = do with_cond(bcx, Load(bcx, option::get(ret_flag))) |bcx| {
|
||||
do option::iter(copy bcx.fcx.loop_ret) |lret| {
|
||||
bcx = do with_cond(bcx, Load(bcx, ret_flag.get())) |bcx| {
|
||||
do option::iter(© bcx.fcx.loop_ret) |lret| {
|
||||
Store(bcx, C_bool(true), lret.flagptr);
|
||||
Store(bcx, C_bool(false), bcx.fcx.llretptr);
|
||||
}
|
||||
|
@ -279,7 +279,7 @@ fn build_closure(bcx0: block,
|
||||
|
||||
// If this is a `for` loop body, add two special environment
|
||||
// variables:
|
||||
do option::iter(include_ret_handle) |flagptr| {
|
||||
do option::iter(&include_ret_handle) |flagptr| {
|
||||
// Flag indicating we have returned (a by-ref bool):
|
||||
let flag_datum = Datum {val: flagptr, ty: ty::mk_bool(tcx),
|
||||
mode: ByRef, source: FromLvalue};
|
||||
@ -375,9 +375,9 @@ fn trans_expr_fn(bcx: block,
|
||||
trans_closure(ccx, sub_path, decl, body, llfn, no_self,
|
||||
bcx.fcx.param_substs, id, |fcx| {
|
||||
load_environment(fcx, cdata_ty, cap_vars,
|
||||
option::is_some(ret_handle), ck);
|
||||
ret_handle.is_some(), ck);
|
||||
}, |bcx| {
|
||||
if option::is_some(is_loop_body) {
|
||||
if is_loop_body.is_some() {
|
||||
Store(bcx, C_bool(true), bcx.fcx.llretptr);
|
||||
}
|
||||
});
|
||||
|
@ -1333,7 +1333,7 @@ fn find_vtable(tcx: ty::ctxt, ps: ¶m_substs,
|
||||
}
|
||||
i += 1u;
|
||||
}
|
||||
option::get(ps.vtables)[vtable_off]
|
||||
ps.vtables.get()[vtable_off]
|
||||
}
|
||||
|
||||
fn dummy_substs(tps: ~[ty::t]) -> ty::substs {
|
||||
|
@ -164,7 +164,7 @@ fn cached_metadata<T: Copy>(cache: metadata_cache, mdtag: int,
|
||||
fn create_compile_unit(cx: @crate_ctxt)
|
||||
-> @metadata<compile_unit_md> unsafe {
|
||||
let cache = get_cache(cx);
|
||||
let crate_name = option::get(cx.dbg_cx).crate_file;
|
||||
let crate_name = cx.dbg_cx.get().crate_file;
|
||||
let tg = CompileUnitTag;
|
||||
match cached_metadata::<@metadata<compile_unit_md>>(cache, tg,
|
||||
|md| md.data.name == crate_name) {
|
||||
@ -194,7 +194,7 @@ fn create_compile_unit(cx: @crate_ctxt)
|
||||
}
|
||||
|
||||
fn get_cache(cx: @crate_ctxt) -> metadata_cache {
|
||||
option::get(cx.dbg_cx).llmetadata
|
||||
cx.dbg_cx.get().llmetadata
|
||||
}
|
||||
|
||||
fn get_file_path_and_dir(work_dir: &str, full_path: &str) -> (~str, ~str) {
|
||||
@ -236,13 +236,13 @@ fn line_from_span(cm: codemap::codemap, sp: span) -> uint {
|
||||
fn create_block(cx: block) -> @metadata<block_md> {
|
||||
let cache = get_cache(cx.ccx());
|
||||
let mut cx = cx;
|
||||
while option::is_none(cx.node_info) {
|
||||
while cx.node_info.is_none() {
|
||||
match cx.parent {
|
||||
Some(b) => cx = b,
|
||||
None => fail
|
||||
}
|
||||
}
|
||||
let sp = option::get(cx.node_info).span;
|
||||
let sp = cx.node_info.get().span;
|
||||
|
||||
let start = codemap::lookup_char_pos(cx.sess().codemap, sp.lo);
|
||||
let fname = start.file.name;
|
||||
@ -395,7 +395,7 @@ fn create_record(cx: @crate_ctxt, t: ty::t, fields: ~[ast::ty_field],
|
||||
let file_node = create_file(cx, fname);
|
||||
let scx = create_structure(file_node,
|
||||
cx.sess.str_of(
|
||||
option::get(cx.dbg_cx).names(~"rec")),
|
||||
cx.dbg_cx.get().names(~"rec")),
|
||||
line_from_span(cx.sess.codemap,
|
||||
span) as int);
|
||||
for fields.each |field| {
|
||||
@ -452,15 +452,15 @@ fn create_composite_type(type_tag: int, name: ~str, file: ValueRef, line: int,
|
||||
lli64(align), // align
|
||||
lli32/*64*/(offset), // offset
|
||||
lli32(0), // flags
|
||||
if option::is_none(derived) {
|
||||
if derived.is_none() {
|
||||
llnull()
|
||||
} else { // derived from
|
||||
option::get(derived)
|
||||
derived.get()
|
||||
},
|
||||
if option::is_none(members) {
|
||||
if members.is_none() {
|
||||
llnull()
|
||||
} else { //members
|
||||
llmdnode(option::get(members))
|
||||
llmdnode(members.get())
|
||||
},
|
||||
lli32(0), // runtime language
|
||||
llnull()
|
||||
@ -711,12 +711,12 @@ fn update_source_pos(cx: block, s: span) {
|
||||
|
||||
fn create_function(fcx: fn_ctxt) -> @metadata<subprogram_md> {
|
||||
let cx = fcx.ccx;
|
||||
let dbg_cx = option::get(cx.dbg_cx);
|
||||
let dbg_cx = cx.dbg_cx.get();
|
||||
|
||||
debug!("~~");
|
||||
log(debug, fcx.id);
|
||||
|
||||
let sp = option::get(fcx.span);
|
||||
let sp = fcx.span.get();
|
||||
log(debug, codemap::span_to_str(sp, cx.sess.codemap));
|
||||
|
||||
let (ident, ret_ty, id) = match cx.tcx.items.get(fcx.id) {
|
||||
|
@ -392,7 +392,7 @@ fn x86_64_tys(atys: ~[TypeRef],
|
||||
}
|
||||
let mut (ret_ty, ret_attr) = x86_64_ty(rty, is_ret_bysret,
|
||||
StructRetAttribute);
|
||||
let sret = option::is_some(ret_attr);
|
||||
let sret = ret_attr.is_some();
|
||||
if sret {
|
||||
arg_tys = vec::append(~[ret_ty], arg_tys);
|
||||
ret_ty = { cast: false,
|
||||
@ -623,7 +623,7 @@ fn trans_foreign_mod(ccx: @crate_ctxt,
|
||||
let arg_ptr = BitCast(bcx, arg_ptr,
|
||||
T_ptr(atys[i].ty));
|
||||
Load(bcx, arg_ptr)
|
||||
} else if option::is_some(attrs[i]) {
|
||||
} else if attrs[i].is_some() {
|
||||
GEPi(bcx, llargbundle, [0u, i])
|
||||
} else {
|
||||
load_inbounds(bcx, llargbundle, [0u, i])
|
||||
@ -938,7 +938,7 @@ fn trans_intrinsic(ccx: @crate_ctxt, decl: ValueRef, item: @ast::foreign_item,
|
||||
let tp_sz = shape::llsize_of_real(ccx, lltp_ty),
|
||||
out_sz = shape::llsize_of_real(ccx, llout_ty);
|
||||
if tp_sz != out_sz {
|
||||
let sp = match ccx.tcx.items.get(option::get(ref_id)) {
|
||||
let sp = match ccx.tcx.items.get(ref_id.get()) {
|
||||
ast_map::node_expr(e) => e.span,
|
||||
_ => fail ~"reinterpret_cast or forget has non-expr arg"
|
||||
};
|
||||
@ -1105,7 +1105,7 @@ fn trans_foreign_fn(ccx: @crate_ctxt, path: ast_map::path, decl: ast::fn_decl,
|
||||
let n = vec::len(atys);
|
||||
while i < n {
|
||||
let mut argval = get_param(llwrapfn, i + j);
|
||||
if option::is_some(attrs[i]) {
|
||||
if attrs[i].is_some() {
|
||||
argval = Load(bcx, argval);
|
||||
store_inbounds(bcx, argval, llargbundle,
|
||||
[0u, i]);
|
||||
|
@ -316,7 +316,7 @@ fn call_tydesc_glue_full(++bcx: block, v: ValueRef, tydesc: ValueRef,
|
||||
|
||||
// When static type info is available, avoid casting parameter because the
|
||||
// function already has the right type. Otherwise cast to generic pointer.
|
||||
let llrawptr = if is_none(static_ti) || is_none(static_glue_fn) {
|
||||
let llrawptr = if static_ti.is_none() || static_glue_fn.is_none() {
|
||||
PointerCast(bcx, v, T_ptr(T_i8()))
|
||||
} else {
|
||||
v
|
||||
@ -397,7 +397,7 @@ fn make_free_glue(bcx: block, v: ValueRef, t: ty::t) {
|
||||
}
|
||||
ty::ty_class(did, ref substs) => {
|
||||
// Call the dtor if there is one
|
||||
do option::map_default(ty::ty_dtor(bcx.tcx(), did), bcx) |dt_id| {
|
||||
do option::map_default(&ty::ty_dtor(bcx.tcx(), did), bcx) |dt_id| {
|
||||
trans_class_drop(bcx, v, dt_id, did, substs)
|
||||
}
|
||||
}
|
||||
|
@ -206,7 +206,7 @@ fn trans_static_method_callee(bcx: block,
|
||||
|
||||
fn method_from_methods(ms: ~[@ast::method], name: ast::ident)
|
||||
-> ast::def_id {
|
||||
local_def(option::get(vec::find(ms, |m| m.ident == name)).id)
|
||||
local_def(option::get(&vec::find(ms, |m| m.ident == name)).id)
|
||||
}
|
||||
|
||||
fn method_with_name(ccx: @crate_ctxt, impl_id: ast::def_id,
|
||||
|
@ -99,7 +99,7 @@ fn monomorphic_fn(ccx: @crate_ctxt,
|
||||
|
||||
ccx.stats.n_monos += 1;
|
||||
|
||||
let depth = option::get_default(ccx.monomorphizing.find(fn_id), 0u);
|
||||
let depth = option::get_default(&ccx.monomorphizing.find(fn_id), 0u);
|
||||
// Random cut-off -- code that needs to instantiate the same function
|
||||
// recursively more than ten times can probably safely be assumed to be
|
||||
// causing an infinite expansion.
|
||||
@ -132,13 +132,13 @@ fn monomorphic_fn(ccx: @crate_ctxt,
|
||||
}
|
||||
ast_map::node_foreign_item(i, _, _) => {
|
||||
let d = mk_lldecl();
|
||||
foreign::trans_intrinsic(ccx, d, i, pt, option::get(psubsts),
|
||||
foreign::trans_intrinsic(ccx, d, i, pt, psubsts.get(),
|
||||
ref_id);
|
||||
d
|
||||
}
|
||||
ast_map::node_variant(v, enum_item, _) => {
|
||||
let tvs = ty::enum_variants(ccx.tcx, local_def(enum_item.id));
|
||||
let this_tv = option::get(vec::find(*tvs, |tv| {
|
||||
let this_tv = option::get(&vec::find(*tvs, |tv| {
|
||||
tv.id.node == fn_id.node}));
|
||||
let d = mk_lldecl();
|
||||
set_inline_hint(d);
|
||||
@ -166,7 +166,7 @@ fn monomorphic_fn(ccx: @crate_ctxt,
|
||||
let d = mk_lldecl();
|
||||
let tp_tys = ty::ty_params_to_tys(ccx.tcx, tps);
|
||||
trans_class_ctor(ccx, pt, ctor.node.dec, ctor.node.body, d,
|
||||
option::get_default(psubsts,
|
||||
option::get_default(&psubsts,
|
||||
{tys:tp_tys, vtables: None, bounds: @~[]}),
|
||||
fn_id.node, parent_id, ctor.span);
|
||||
d
|
||||
|
@ -104,14 +104,14 @@ fn traverse_public_item(cx: ctx, item: @item) {
|
||||
}
|
||||
}
|
||||
item_class(struct_def, tps) => {
|
||||
do option::iter(struct_def.ctor) |ctor| {
|
||||
do option::iter(&struct_def.ctor) |ctor| {
|
||||
cx.rmap.insert(ctor.node.id, ());
|
||||
if tps.len() > 0u || attr::find_inline_attr(ctor.node.attrs)
|
||||
!= attr::ia_none {
|
||||
traverse_inline_body(cx, ctor.node.body);
|
||||
}
|
||||
}
|
||||
do option::iter(struct_def.dtor) |dtor| {
|
||||
do option::iter(&struct_def.dtor) |dtor| {
|
||||
cx.rmap.insert(dtor.node.id, ());
|
||||
if tps.len() > 0u || attr::find_inline_attr(dtor.node.attrs)
|
||||
!= attr::ia_none {
|
||||
|
@ -58,7 +58,7 @@ impl reflector {
|
||||
|
||||
fn visit(ty_name: ~str, args: ~[ValueRef]) {
|
||||
let tcx = self.bcx.tcx();
|
||||
let mth_idx = option::get(ty::method_idx(
|
||||
let mth_idx = option::get(&ty::method_idx(
|
||||
tcx.sess.ident_of(~"visit_" + ty_name),
|
||||
*self.visitor_methods));
|
||||
let mth_ty = ty::mk_fn(tcx, self.visitor_methods[mth_idx].fty);
|
||||
|
@ -351,11 +351,11 @@ fn shape_of(ccx: @crate_ctxt, t: ty::t) -> ~[u8] {
|
||||
// same as records, unless there's a dtor
|
||||
let tps = substs.tps;
|
||||
let m_dtor_did = ty::ty_dtor(ccx.tcx, did);
|
||||
let mut s = if option::is_some(m_dtor_did) {
|
||||
let mut s = if m_dtor_did.is_some() {
|
||||
~[shape_res]
|
||||
}
|
||||
else { ~[shape_struct] }, sub = ~[];
|
||||
do option::iter(m_dtor_did) |dtor_did| {
|
||||
do m_dtor_did.iter |dtor_did| {
|
||||
let ri = @{did: dtor_did, parent_id: Some(did), tps: tps};
|
||||
let id = ccx.shape_cx.resources.intern(ri);
|
||||
add_u16(s, id as u16);
|
||||
@ -601,7 +601,7 @@ fn gen_resource_shapes(ccx: @crate_ctxt) -> ValueRef {
|
||||
for uint::range(0u, len) |i| {
|
||||
let ri = ccx.shape_cx.resources.get(i);
|
||||
for ri.tps.each() |s| { assert !ty::type_has_params(*s); }
|
||||
do option::iter(ri.parent_id) |id| {
|
||||
do ri.parent_id.iter |id| {
|
||||
dtors += ~[trans::base::get_res_dtor(ccx, ri.did, id, ri.tps)];
|
||||
}
|
||||
}
|
||||
@ -630,7 +630,7 @@ fn force_declare_tydescs(ccx: @crate_ctxt) {
|
||||
for uint::range(0u, len) |i| {
|
||||
let ri = ccx.shape_cx.resources.get(i);
|
||||
for ri.tps.each() |s| { assert !ty::type_has_params(*s); }
|
||||
do option::iter(ri.parent_id) |id| {
|
||||
do ri.parent_id.iter |id| {
|
||||
trans::base::get_res_dtor(ccx, ri.did, id, ri.tps);
|
||||
}
|
||||
}
|
||||
@ -782,7 +782,7 @@ fn simplify_type(tcx: ty::ctxt, typ: ty::t) -> ty::t {
|
||||
// Reduce a class type to a record type in which all the fields are
|
||||
// simplified
|
||||
ty::ty_class(did, ref substs) => {
|
||||
let simpl_fields = (if is_some(ty::ty_dtor(tcx, did)) {
|
||||
let simpl_fields = (if ty::ty_dtor(tcx, did).is_some() {
|
||||
// remember the drop flag
|
||||
~[{ident: syntax::parse::token::special_idents::dtor,
|
||||
mt: {ty: ty::mk_u8(tcx),
|
||||
|
@ -146,7 +146,7 @@ fn type_needs_inner(cx: ctx, use_: uint, ty: ty::t,
|
||||
ty::ty_fn(_) | ty::ty_ptr(_) | ty::ty_rptr(_, _)
|
||||
| ty::ty_trait(_, _, _) => false,
|
||||
ty::ty_enum(did, substs) => {
|
||||
if option::is_none(list::find(enums_seen, |id| *id == did)) {
|
||||
if option::is_none(&list::find(enums_seen, |id| *id == did)) {
|
||||
let seen = @Cons(did, enums_seen);
|
||||
for vec::each(*ty::enum_variants(cx.ccx.tcx, did)) |v| {
|
||||
for vec::each(v.args) |aty| {
|
||||
@ -234,10 +234,10 @@ fn mark_for_expr(cx: ctx, e: @expr) {
|
||||
let base_ty = ty::node_id_to_type(cx.ccx.tcx, base.id);
|
||||
type_needs(cx, use_repr, ty::type_autoderef(cx.ccx.tcx, base_ty));
|
||||
|
||||
do option::iter(cx.ccx.maps.method_map.find(e.id)) |mth| {
|
||||
do option::iter(&cx.ccx.maps.method_map.find(e.id)) |mth| {
|
||||
match mth.origin {
|
||||
typeck::method_static(did) => {
|
||||
do option::iter(cx.ccx.tcx.node_type_substs.find(e.id)) |ts| {
|
||||
do cx.ccx.tcx.node_type_substs.find(e.id).iter |ts| {
|
||||
do vec::iter2(type_uses_for(cx.ccx, did, ts.len()), ts)
|
||||
|uses, subst| { type_needs(cx, uses, subst)}
|
||||
}
|
||||
@ -289,7 +289,7 @@ fn handle_body(cx: ctx, body: blk) {
|
||||
},
|
||||
visit_block: |b, cx, v| {
|
||||
visit::visit_block(b, cx, v);
|
||||
do option::iter(b.node.expr) |e| {
|
||||
do option::iter(&b.node.expr) |e| {
|
||||
node_type_needs(cx, use_repr, e.id);
|
||||
}
|
||||
},
|
||||
|
@ -1691,7 +1691,7 @@ fn type_needs_drop(cx: ctxt, ty: t) -> bool {
|
||||
}
|
||||
ty_class(did, ref substs) => {
|
||||
// Any class with a dtor needs a drop
|
||||
option::is_some(ty_dtor(cx, did)) || {
|
||||
ty_dtor(cx, did).is_some() || {
|
||||
for vec::each(ty::class_items_as_fields(cx, did, substs)) |f| {
|
||||
if type_needs_drop(cx, f.mt.ty) { accum = true; }
|
||||
}
|
||||
@ -3454,7 +3454,7 @@ fn impl_traits(cx: ctxt, id: ast::def_id) -> ~[t] {
|
||||
_},
|
||||
_)) => {
|
||||
|
||||
do option::map_default(opt_trait, ~[]) |trait_ref| {
|
||||
do option::map_default(&opt_trait, ~[]) |trait_ref| {
|
||||
~[node_id_to_type(cx, trait_ref.ref_id)]
|
||||
}
|
||||
}
|
||||
@ -3519,7 +3519,7 @@ fn ty_dtor(cx: ctxt, class_id: def_id) -> Option<def_id> {
|
||||
}
|
||||
|
||||
fn has_dtor(cx: ctxt, class_id: def_id) -> bool {
|
||||
option::is_some(ty_dtor(cx, class_id))
|
||||
ty_dtor(cx, class_id).is_some()
|
||||
}
|
||||
|
||||
fn item_path(cx: ctxt, id: ast::def_id) -> ast_map::path {
|
||||
|
@ -176,7 +176,7 @@ trait get_and_find_region {
|
||||
|
||||
impl isr_alist: get_and_find_region {
|
||||
fn get(br: ty::bound_region) -> ty::region {
|
||||
option::get(self.find(br))
|
||||
self.find(br).get()
|
||||
}
|
||||
|
||||
fn find(br: ty::bound_region) -> Option<ty::region> {
|
||||
@ -227,7 +227,7 @@ fn check_fn(ccx: @crate_ctxt,
|
||||
// the node_id of the body block.
|
||||
|
||||
let {isr, self_info, fn_ty} = {
|
||||
let old_isr = option::map_default(old_fcx, @Nil,
|
||||
let old_isr = option::map_default(&old_fcx, @Nil,
|
||||
|fcx| fcx.in_scope_regions);
|
||||
replace_bound_regions_in_fn_ty(tcx, old_isr, self_info, fn_ty,
|
||||
|br| ty::re_free(body.node.id, br))
|
||||
@ -239,7 +239,7 @@ fn check_fn(ccx: @crate_ctxt,
|
||||
debug!("check_fn(arg_tys=%?, ret_ty=%?, self_info.self_ty=%?)",
|
||||
arg_tys.map(|a| ty_to_str(tcx, *a)),
|
||||
ty_to_str(tcx, ret_ty),
|
||||
option::map(self_info, |s| ty_to_str(tcx, s.self_ty)));
|
||||
option::map(&self_info, |s| ty_to_str(tcx, s.self_ty)));
|
||||
|
||||
// ______________________________________________________________________
|
||||
// Create the function context. This is either derived from scratch or,
|
||||
@ -258,7 +258,7 @@ fn check_fn(ccx: @crate_ctxt,
|
||||
};
|
||||
|
||||
let indirect_ret_ty = if indirect_ret {
|
||||
let ofcx = option::get(old_fcx);
|
||||
let ofcx = old_fcx.get();
|
||||
match ofcx.indirect_ret_ty {
|
||||
Some(t) => Some(t),
|
||||
None => Some(ofcx.ret_ty)
|
||||
@ -316,7 +316,7 @@ fn check_fn(ccx: @crate_ctxt,
|
||||
// force any remaining type vars to be resolved.
|
||||
// If we have an enclosing function scope, our type variables will be
|
||||
// resolved when the enclosing scope finishes up.
|
||||
if option::is_none(old_fcx) {
|
||||
if old_fcx.is_none() {
|
||||
vtable::resolve_in_block(fcx, body);
|
||||
regionck::regionck_fn(fcx, decl, body);
|
||||
writeback::resolve_type_vars_in_fn(fcx, decl, body, self_info);
|
||||
@ -451,7 +451,7 @@ fn check_struct(ccx: @crate_ctxt, struct_def: @ast::struct_def,
|
||||
let tcx = ccx.tcx;
|
||||
let self_ty = ty::node_id_to_type(tcx, id);
|
||||
|
||||
do option::iter(struct_def.ctor) |ctor| {
|
||||
do option::iter(&struct_def.ctor) |ctor| {
|
||||
let class_t = {self_ty: self_ty,
|
||||
self_id: ctor.node.self_id,
|
||||
def_id: local_def(id),
|
||||
@ -463,7 +463,7 @@ fn check_struct(ccx: @crate_ctxt, struct_def: @ast::struct_def,
|
||||
Some(class_t));
|
||||
}
|
||||
|
||||
do option::iter(struct_def.dtor) |dtor| {
|
||||
do option::iter(&struct_def.dtor) |dtor| {
|
||||
let class_t = {self_ty: self_ty,
|
||||
self_id: dtor.node.self_id,
|
||||
def_id: local_def(id),
|
||||
@ -935,7 +935,7 @@ fn lookup_field_ty(tcx: ty::ctxt,
|
||||
substs: &ty::substs) -> Option<ty::t> {
|
||||
|
||||
let o_field = vec::find(items, |f| f.ident == fieldname);
|
||||
do option::map(o_field) |f| {
|
||||
do o_field.map() |f| {
|
||||
ty::lookup_field_type(tcx, class_id, f.id, substs)
|
||||
}
|
||||
}
|
||||
@ -1864,7 +1864,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
|
||||
fcx.write_ty(id, typ);
|
||||
}
|
||||
ast::expr_rec(fields, base) => {
|
||||
option::iter(base, |b| { check_expr(fcx, b, expected); });
|
||||
option::iter(&base, |b| { check_expr(fcx, b, expected); });
|
||||
let expected = if expected.is_none() && base.is_some() {
|
||||
Some(fcx.expr_ty(base.get()))
|
||||
} else { expected };
|
||||
|
@ -163,7 +163,7 @@ fn check_pat_variant(pcx: pat_ctxt, pat: @ast::pat, path: @ast::path,
|
||||
tcx.sess.span_fatal(pat.span, s);
|
||||
}
|
||||
|
||||
do option::iter(subpats) |pats| {
|
||||
do subpats.iter() |pats| {
|
||||
do vec::iter2(pats, arg_types) |subpat, arg_ty| {
|
||||
check_pat(pcx, subpat, arg_ty);
|
||||
}
|
||||
|
@ -497,7 +497,7 @@ fn convert_struct(ccx: @crate_ctxt,
|
||||
tpt: ty::ty_param_bounds_and_ty,
|
||||
id: ast::node_id) {
|
||||
let tcx = ccx.tcx;
|
||||
do option::iter(struct_def.ctor) |ctor| {
|
||||
do option::iter(&struct_def.ctor) |ctor| {
|
||||
// Write the ctor type
|
||||
let t_args = ctor.node.dec.inputs.map(
|
||||
|a| ty_of_arg(ccx, type_rscope(rp), *a, None) );
|
||||
@ -522,7 +522,7 @@ fn convert_struct(ccx: @crate_ctxt,
|
||||
ty: t_ctor});
|
||||
}
|
||||
|
||||
do option::iter(struct_def.dtor) |dtor| {
|
||||
do option::iter(&struct_def.dtor) |dtor| {
|
||||
// Write the dtor type
|
||||
let t_dtor = ty::mk_fn(
|
||||
tcx,
|
||||
|
@ -52,7 +52,7 @@ fn fold_crate(
|
||||
{
|
||||
topmod: doc::ModDoc_({
|
||||
item: {
|
||||
name: option::get_default(attrs.name, doc.topmod.name()),
|
||||
name: option::get_default(&attrs.name, doc.topmod.name()),
|
||||
.. doc.topmod.item
|
||||
},
|
||||
.. *doc.topmod
|
||||
@ -150,7 +150,7 @@ fn fold_enum(
|
||||
node: ast::item_enum(enum_definition, _), _
|
||||
}, _) => {
|
||||
let ast_variant = option::get(
|
||||
vec::find(enum_definition.variants, |v| {
|
||||
&vec::find(enum_definition.variants, |v| {
|
||||
to_str(v.node.name) == variant.name
|
||||
}));
|
||||
|
||||
|
@ -159,16 +159,16 @@ fn config_from_opts(
|
||||
let result = result::Ok(config);
|
||||
let result = do result::chain(result) |config| {
|
||||
let output_dir = getopts::opt_maybe_str(matches, opt_output_dir());
|
||||
let output_dir = option::map(output_dir, |s| Path(s));
|
||||
let output_dir = output_dir.map(|s| Path(s));
|
||||
result::Ok({
|
||||
output_dir: option::get_default(output_dir, config.output_dir),
|
||||
output_dir: output_dir.get_default(config.output_dir),
|
||||
.. config
|
||||
})
|
||||
};
|
||||
let result = do result::chain(result) |config| {
|
||||
let output_format = getopts::opt_maybe_str(
|
||||
matches, opt_output_format());
|
||||
do option::map_default(output_format, result::Ok(config))
|
||||
do output_format.map_default(result::Ok(config))
|
||||
|output_format| {
|
||||
do result::chain(parse_output_format(output_format))
|
||||
|output_format| {
|
||||
@ -183,7 +183,7 @@ fn config_from_opts(
|
||||
let result = do result::chain(result) |config| {
|
||||
let output_style =
|
||||
getopts::opt_maybe_str(matches, opt_output_style());
|
||||
do option::map_default(output_style, result::Ok(config))
|
||||
do output_style.map_default(result::Ok(config))
|
||||
|output_style| {
|
||||
do result::chain(parse_output_style(output_style))
|
||||
|output_style| {
|
||||
@ -251,7 +251,7 @@ fn maybe_find_pandoc(
|
||||
output.status == 0
|
||||
};
|
||||
|
||||
if option::is_some(pandoc) {
|
||||
if pandoc.is_some() {
|
||||
result::Ok(pandoc)
|
||||
} else {
|
||||
result::Err(~"couldn't find pandoc")
|
||||
|
@ -94,11 +94,11 @@ mod test {
|
||||
}
|
||||
|
||||
fn extract(desc: Option<~str>) -> Option<~str> {
|
||||
if option::is_none(desc) {
|
||||
if desc.is_none() {
|
||||
return None
|
||||
}
|
||||
|
||||
parse_desc(option::get(desc))
|
||||
parse_desc(desc.get())
|
||||
}
|
||||
|
||||
fn parse_desc(desc: ~str) -> Option<~str> {
|
||||
|
@ -635,7 +635,7 @@ impl IndexEntry : cmp::Eq {
|
||||
|
||||
impl Doc {
|
||||
fn CrateDoc() -> CrateDoc {
|
||||
option::get(vec::foldl(None, self.pages, |_m, page| {
|
||||
option::get(&vec::foldl(None, self.pages, |_m, page| {
|
||||
match page {
|
||||
doc::CratePage(doc) => Some(doc),
|
||||
_ => None
|
||||
|
@ -152,13 +152,13 @@ fn should_index_mod_contents() {
|
||||
config::DocPerCrate,
|
||||
~"mod a { } fn b() { }"
|
||||
);
|
||||
assert option::get(doc.cratemod().index).entries[0] == {
|
||||
assert doc.cratemod().index.get().entries[0] == {
|
||||
kind: ~"Module",
|
||||
name: ~"a",
|
||||
brief: None,
|
||||
link: ~"#module-a"
|
||||
};
|
||||
assert option::get(doc.cratemod().index).entries[1] == {
|
||||
assert doc.cratemod().index.get().entries[1] == {
|
||||
kind: ~"Function",
|
||||
name: ~"b",
|
||||
brief: None,
|
||||
@ -172,13 +172,13 @@ fn should_index_mod_contents_multi_page() {
|
||||
config::DocPerMod,
|
||||
~"mod a { } fn b() { }"
|
||||
);
|
||||
assert option::get(doc.cratemod().index).entries[0] == {
|
||||
assert doc.cratemod().index.get().entries[0] == {
|
||||
kind: ~"Module",
|
||||
name: ~"a",
|
||||
brief: None,
|
||||
link: ~"a.html"
|
||||
};
|
||||
assert option::get(doc.cratemod().index).entries[1] == {
|
||||
assert doc.cratemod().index.get().entries[1] == {
|
||||
kind: ~"Function",
|
||||
name: ~"b",
|
||||
brief: None,
|
||||
@ -192,7 +192,7 @@ fn should_index_foreign_mod_pages() {
|
||||
config::DocPerMod,
|
||||
~"extern mod a { }"
|
||||
);
|
||||
assert option::get(doc.cratemod().index).entries[0] == {
|
||||
assert doc.cratemod().index.get().entries[0] == {
|
||||
kind: ~"Foreign module",
|
||||
name: ~"a",
|
||||
brief: None,
|
||||
@ -206,7 +206,7 @@ fn should_add_brief_desc_to_index() {
|
||||
config::DocPerMod,
|
||||
~"#[doc = \"test\"] mod a { }"
|
||||
);
|
||||
assert option::get(doc.cratemod().index).entries[0].brief
|
||||
assert doc.cratemod().index.get().entries[0].brief
|
||||
== Some(~"test");
|
||||
}
|
||||
|
||||
@ -216,7 +216,7 @@ fn should_index_foreign_mod_contents() {
|
||||
config::DocPerCrate,
|
||||
~"extern mod a { fn b(); }"
|
||||
);
|
||||
assert option::get(doc.cratemod().nmods()[0].index).entries[0] == {
|
||||
assert doc.cratemod().nmods()[0].index.get().entries[0] == {
|
||||
kind: ~"Function",
|
||||
name: ~"b",
|
||||
brief: None,
|
||||
|
@ -66,10 +66,10 @@ fn should_write_modules_last() {
|
||||
fn d() { }"
|
||||
);
|
||||
|
||||
let idx_a = option::get(str::find_str(markdown, ~"# Module `a`"));
|
||||
let idx_b = option::get(str::find_str(markdown, ~"## Function `b`"));
|
||||
let idx_c = option::get(str::find_str(markdown, ~"# Module `c`"));
|
||||
let idx_d = option::get(str::find_str(markdown, ~"## Function `d`"));
|
||||
let idx_a = str::find_str(markdown, ~"# Module `a`").get();
|
||||
let idx_b = str::find_str(markdown, ~"## Function `b`").get();
|
||||
let idx_c = str::find_str(markdown, ~"# Module `c`").get();
|
||||
let idx_d = str::find_str(markdown, ~"## Function `d`").get();
|
||||
|
||||
assert idx_b < idx_d;
|
||||
assert idx_d < idx_a;
|
||||
@ -227,8 +227,8 @@ fn header_name(doc: doc::ItemTag) -> ~str {
|
||||
fullpath
|
||||
}
|
||||
doc::ImplTag(doc) => {
|
||||
assert option::is_some(doc.self_ty);
|
||||
let self_ty = option::get(doc.self_ty);
|
||||
assert doc.self_ty.is_some();
|
||||
let self_ty = doc.self_ty.get();
|
||||
let mut trait_part = ~"";
|
||||
for doc.trait_types.eachi |i, trait_type| {
|
||||
if i == 0 {
|
||||
@ -345,8 +345,8 @@ fn write_mod_contents(
|
||||
doc: doc::ModDoc
|
||||
) {
|
||||
write_common(ctxt, doc.desc(), doc.sections());
|
||||
if option::is_some(doc.index) {
|
||||
write_index(ctxt, option::get(doc.index));
|
||||
if doc.index.is_some() {
|
||||
write_index(ctxt, doc.index.get());
|
||||
}
|
||||
|
||||
for doc.items.each |itemTag| {
|
||||
@ -405,9 +405,9 @@ fn write_index(ctxt: Ctxt, index: doc::Index) {
|
||||
for index.entries.each |entry| {
|
||||
let header = header_text_(entry.kind, entry.name);
|
||||
let id = entry.link;
|
||||
if option::is_some(entry.brief) {
|
||||
if entry.brief.is_some() {
|
||||
ctxt.w.write_line(fmt!("* [%s](%s) - %s",
|
||||
header, id, option::get(entry.brief)));
|
||||
header, id, entry.brief.get()));
|
||||
} else {
|
||||
ctxt.w.write_line(fmt!("* [%s](%s)", header, id));
|
||||
}
|
||||
@ -448,8 +448,8 @@ fn should_write_index_for_foreign_mods() {
|
||||
|
||||
fn write_nmod(ctxt: Ctxt, doc: doc::NmodDoc) {
|
||||
write_common(ctxt, doc.desc(), doc.sections());
|
||||
if option::is_some(doc.index) {
|
||||
write_index(ctxt, option::get(doc.index));
|
||||
if doc.index.is_some() {
|
||||
write_index(ctxt, doc.index.get());
|
||||
}
|
||||
|
||||
for doc.fns.each |FnDoc| {
|
||||
@ -623,8 +623,8 @@ fn write_variants(
|
||||
}
|
||||
|
||||
fn write_variant(ctxt: Ctxt, doc: doc::VariantDoc) {
|
||||
assert option::is_some(doc.sig);
|
||||
let sig = option::get(doc.sig);
|
||||
assert doc.sig.is_some();
|
||||
let sig = doc.sig.get();
|
||||
match doc.desc {
|
||||
Some(desc) => {
|
||||
ctxt.w.write_line(fmt!("* `%s` - %s", sig, desc));
|
||||
|
@ -74,8 +74,8 @@ fn pandoc_writer(
|
||||
config: config::Config,
|
||||
page: doc::Page
|
||||
) -> Writer {
|
||||
assert option::is_some(config.pandoc_cmd);
|
||||
let pandoc_cmd = option::get(config.pandoc_cmd);
|
||||
assert config.pandoc_cmd.is_some();
|
||||
let pandoc_cmd = config.pandoc_cmd.get();
|
||||
let filename = make_local_filename(config, page);
|
||||
|
||||
let pandoc_args = ~[
|
||||
|
@ -45,7 +45,7 @@ fn make_doc_from_pages(page_port: PagePort) -> doc::Doc {
|
||||
let mut pages = ~[];
|
||||
loop {
|
||||
let val = comm::recv(page_port);
|
||||
if option::is_some(val) {
|
||||
if val.is_some() {
|
||||
pages += ~[option::unwrap(val)];
|
||||
} else {
|
||||
break;
|
||||
|
@ -84,11 +84,11 @@ fn sectionalize(desc: Option<~str>) -> (Option<~str>, ~[doc::Section]) {
|
||||
* and remove each header and accompanying text into section records.
|
||||
*/
|
||||
|
||||
if option::is_none(desc) {
|
||||
if desc.is_none() {
|
||||
return (None, ~[]);
|
||||
}
|
||||
|
||||
let lines = str::lines(option::get(desc));
|
||||
let lines = str::lines(desc.get());
|
||||
|
||||
let mut new_desc = None::<~str>;
|
||||
let mut current_section = None;
|
||||
@ -97,8 +97,8 @@ fn sectionalize(desc: Option<~str>) -> (Option<~str>, ~[doc::Section]) {
|
||||
for lines.each |line| {
|
||||
match parse_header(*line) {
|
||||
Some(header) => {
|
||||
if option::is_some(current_section) {
|
||||
sections += ~[option::get(current_section)];
|
||||
if current_section.is_some() {
|
||||
sections += ~[current_section.get()];
|
||||
}
|
||||
current_section = Some({
|
||||
header: header,
|
||||
@ -128,8 +128,8 @@ fn sectionalize(desc: Option<~str>) -> (Option<~str>, ~[doc::Section]) {
|
||||
}
|
||||
}
|
||||
|
||||
if option::is_some(current_section) {
|
||||
sections += ~[option::get(current_section)];
|
||||
if current_section.is_some() {
|
||||
sections += ~[current_section.get()];
|
||||
}
|
||||
|
||||
(new_desc, sections)
|
||||
@ -190,10 +190,10 @@ fn should_remove_section_text_from_main_desc() {
|
||||
mod a {
|
||||
#[legacy_exports]; }");
|
||||
assert !str::contains(
|
||||
option::get(doc.cratemod().mods()[0].desc()),
|
||||
doc.cratemod().mods()[0].desc().get(),
|
||||
~"Header");
|
||||
assert !str::contains(
|
||||
option::get(doc.cratemod().mods()[0].desc()),
|
||||
doc.cratemod().mods()[0].desc().get(),
|
||||
~"Body");
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,7 @@ fn run(
|
||||
}
|
||||
|
||||
fn maybe_apply_op(op: Op, s: Option<~str>) -> Option<~str> {
|
||||
option::map(s, |s| op(s) )
|
||||
s.map(|s| op(s) )
|
||||
}
|
||||
|
||||
fn fold_item(fold: fold::Fold<Op>, doc: doc::ItemDoc) -> doc::ItemDoc {
|
||||
|
@ -117,10 +117,10 @@ fn fold_enum(
|
||||
ast_map::node_item(@{
|
||||
node: ast::item_enum(enum_definition, _), _
|
||||
}, _) => {
|
||||
let ast_variant = option::get(
|
||||
let ast_variant =
|
||||
do vec::find(enum_definition.variants) |v| {
|
||||
to_str(v.node.name) == variant.name
|
||||
});
|
||||
}.get();
|
||||
|
||||
pprust::variant_to_str(ast_variant, extract::interner())
|
||||
}
|
||||
|
@ -52,8 +52,8 @@ fn run(args: &[~str]) {
|
||||
|
||||
let to_child = SharedChan(to_child);
|
||||
|
||||
let size = option::get(uint::from_str(args[1]));
|
||||
let workers = option::get(uint::from_str(args[2]));
|
||||
let size = uint::from_str(args[1]).get();
|
||||
let workers = uint::from_str(args[2]).get();
|
||||
let num_bytes = 100;
|
||||
let start = std::time::precise_time_s();
|
||||
let mut worker_results = ~[];
|
||||
|
@ -48,8 +48,8 @@ fn run(args: &[~str]) {
|
||||
let from_parent = PortSet();
|
||||
from_parent.add(from_parent_);
|
||||
|
||||
let size = option::get(uint::from_str(args[1]));
|
||||
let workers = option::get(uint::from_str(args[2]));
|
||||
let size = uint::from_str(args[1]).get();
|
||||
let workers = uint::from_str(args[2]).get();
|
||||
let num_bytes = 100;
|
||||
let start = std::time::precise_time_s();
|
||||
let mut worker_results = ~[];
|
||||
|
@ -65,8 +65,8 @@ fn main(args: ~[~str]) {
|
||||
copy args
|
||||
};
|
||||
|
||||
let num_tasks = option::get(uint::from_str(args[1]));
|
||||
let msg_per_task = option::get(uint::from_str(args[2]));
|
||||
let num_tasks = uint::from_str(args[1]).get();
|
||||
let msg_per_task = uint::from_str(args[2]).get();
|
||||
|
||||
let (num_chan, num_port) = init();
|
||||
let mut num_chan = Some(num_chan);
|
||||
|
@ -61,8 +61,8 @@ fn main(args: ~[~str]) {
|
||||
copy args
|
||||
};
|
||||
|
||||
let num_tasks = option::get(uint::from_str(args[1]));
|
||||
let msg_per_task = option::get(uint::from_str(args[2]));
|
||||
let num_tasks = uint::from_str(args[1]).get();
|
||||
let msg_per_task = uint::from_str(args[2]).get();
|
||||
|
||||
let (num_chan, num_port) = ring::init();
|
||||
let mut num_chan = Some(num_chan);
|
||||
|
@ -65,8 +65,8 @@ fn main(args: ~[~str]) {
|
||||
copy args
|
||||
};
|
||||
|
||||
let num_tasks = option::get(uint::from_str(args[1]));
|
||||
let msg_per_task = option::get(uint::from_str(args[2]));
|
||||
let num_tasks = uint::from_str(args[1]).get();
|
||||
let msg_per_task = uint::from_str(args[2]).get();
|
||||
|
||||
let (num_chan, num_port) = init();
|
||||
let mut num_chan = Some(num_chan);
|
||||
|
@ -30,8 +30,8 @@ fn main(args: ~[~str]) {
|
||||
args
|
||||
};
|
||||
|
||||
let num_tasks = option::get(uint::from_str(args[1]));
|
||||
let msg_per_task = option::get(uint::from_str(args[2]));
|
||||
let num_tasks = uint::from_str(args[1]).get();
|
||||
let msg_per_task = uint::from_str(args[2]).get();
|
||||
|
||||
let num_port = Port();
|
||||
let mut num_chan = Chan(num_port);
|
||||
|
@ -31,8 +31,8 @@ fn run(args: ~[~str]) {
|
||||
let (from_child, to_child) = do task::spawn_conversation |po, ch| {
|
||||
server(po, ch);
|
||||
};
|
||||
let size = option::get(uint::from_str(args[1]));
|
||||
let workers = option::get(uint::from_str(args[2]));
|
||||
let size = uint::from_str(args[1]).get();
|
||||
let workers = uint::from_str(args[2]).get();
|
||||
let start = std::time::precise_time_s();
|
||||
let mut worker_results = ~[];
|
||||
for uint::range(0u, workers) |_i| {
|
||||
|
@ -95,8 +95,8 @@ fn main(args: ~[~str]) {
|
||||
if opts.stress {
|
||||
stress(2);
|
||||
} else {
|
||||
let max = option::get(uint::parse_bytes(str::to_bytes(args[1]),
|
||||
10u)) as int;
|
||||
let max = uint::parse_bytes(str::to_bytes(args[1]),
|
||||
10u).get() as int;
|
||||
|
||||
let num_trials = 10;
|
||||
|
||||
|
@ -37,9 +37,9 @@ fn read_grid(f: io::Reader) -> grid_t {
|
||||
while !f.eof() {
|
||||
let comps = str::split_char(str::trim(f.read_line()), ',');
|
||||
if vec::len(comps) >= 3u {
|
||||
let row = option::get(uint::from_str(comps[0])) as u8;
|
||||
let col = option::get(uint::from_str(comps[1])) as u8;
|
||||
g[row][col] = option::get(uint::from_str(comps[2])) as u8;
|
||||
let row = uint::from_str(comps[0]).get() as u8;
|
||||
let col = uint::from_str(comps[1]).get() as u8;
|
||||
g[row][col] = uint::from_str(comps[2]).get() as u8;
|
||||
}
|
||||
}
|
||||
return grid_ctor(g);
|
||||
|
@ -20,10 +20,10 @@ fn checktests() {
|
||||
let tests = __test::tests();
|
||||
|
||||
let shouldignore = option::get(
|
||||
vec::find(tests, |t| t.name == ~"shouldignore" ));
|
||||
&vec::find(tests, |t| t.name == ~"shouldignore" ));
|
||||
assert shouldignore.ignore == true;
|
||||
|
||||
let shouldnotignore = option::get(
|
||||
vec::find(tests, |t| t.name == ~"shouldnotignore" ));
|
||||
&vec::find(tests, |t| t.name == ~"shouldnotignore" ));
|
||||
assert shouldnotignore.ignore == false;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user