about summary refs log tree commit diff
path: root/src/libsyntax/print
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2013-08-05 16:47:01 -0700
committerbors <bors@rust-lang.org>2013-08-05 16:47:01 -0700
commitbbda3fa9383dba653b20bd064102caceef91897a (patch)
tree8fa4abc474568ca3a63992b5eea6cf62b7e04259 /src/libsyntax/print
parent29099e450a912cfcd0a0ccc72f55751bc2e209f2 (diff)
parent0ac7a219f043d3b1c8c239089d9dd6e6c9fa830b (diff)
downloadrust-bbda3fa9383dba653b20bd064102caceef91897a.tar.gz
rust-bbda3fa9383dba653b20bd064102caceef91897a.zip
auto merge of #8288 : Kimundi/rust/opteitres4, r=brson
This is an alternative version to https://github.com/mozilla/rust/pull/8268, where instead of transitioning to `get()` completely, I transitioned to `unwrap()` completely.

My reasoning for also opening this PR is that having two different functions with identical behavior on a common datatype is bad for consistency and confusing for users, and should be solved as soon as possible. The fact that apparently half the code uses `get()`, and the other half `unwrap()` only makes it worse.

If the final naming decision ends up different, there needs to be a big renaming anyway, but until then it should at least be consistent.

---

- Made naming schemes consistent between Option, Result and Either
- Lifted the quality of the either and result module to that of option
- Changed Options Add implementation to work like the maybe Monad (return None if any of the inputs is None)  
  See https://github.com/mozilla/rust/issues/6002, especially my last comment.
- Removed duplicate Option::get and renamed all related functions to use the term `unwrap` instead  
  See also https://github.com/mozilla/rust/issues/7887.

Todo: 

Adding testcases for all function in the three modules. Even without the few functions I added, the coverage wasn't complete to begin with. But I'd rather do that as a follow up PR, I've touched to much code here already, need to go through them again later.
Diffstat (limited to 'src/libsyntax/print')
-rw-r--r--src/libsyntax/print/pprust.rs10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs
index 174b0f8e451..f517179f603 100644
--- a/src/libsyntax/print/pprust.rs
+++ b/src/libsyntax/print/pprust.rs
@@ -874,7 +874,7 @@ pub fn print_attribute(s: @ps, attr: &ast::Attribute) {
     hardbreak_if_not_bol(s);
     maybe_print_comment(s, attr.span.lo);
     if attr.node.is_sugared_doc {
-        let comment = attr.value_str().get();
+        let comment = attr.value_str().unwrap();
         word(s.s, comment);
     } else {
         word(s.s, "#[");
@@ -1085,7 +1085,7 @@ pub fn print_call_post(s: @ps,
     }
     if sugar != ast::NoSugar {
         nbsp(s);
-        match blk.get().node {
+        match blk.unwrap().node {
           // need to handle closures specifically
           ast::expr_do_body(e) => {
             end(s); // we close our head box; closure
@@ -1095,7 +1095,7 @@ pub fn print_call_post(s: @ps,
           }
           _ => {
             // not sure if this can happen.
-            print_expr(s, blk.get());
+            print_expr(s, blk.unwrap());
           }
         }
     }
@@ -1323,13 +1323,13 @@ pub fn print_expr(s: @ps, expr: &ast::expr) {
         assert!(body.stmts.is_empty());
         assert!(body.expr.is_some());
         // we extract the block, so as not to create another set of boxes
-        match body.expr.get().node {
+        match body.expr.unwrap().node {
             ast::expr_block(ref blk) => {
                 print_block_unclosed(s, blk);
             }
             _ => {
                 // this is a bare expression
-                print_expr(s, body.expr.get());
+                print_expr(s, body.expr.unwrap());
                 end(s); // need to close a box
             }
         }