use std::str;
use std::path::Path;
use std::process::Command;

extern crate capnpc;

fn main() {

    // CAPNP_INCLUDE_DIR=$(shell dirname $(shell which capnp))/../include

    let prefix = {
        let output = Command::new("which")
                             .arg("capnp")
                             .output()
                             .unwrap().stdout;

        let path = Path::new(str::from_utf8(&output).unwrap());
        let mut path1 = path.parent().unwrap().parent().unwrap().to_path_buf();
        path1.push("include/capnp");
        path1
    };

    capnpc::compile(&prefix,
                    &[&prefix.clone().join("rpc.capnp"),
                      &prefix.join("rpc-twoparty.capnp")]).unwrap();
}

extern crate capnpc;

fn main() {

    // CAPNP_INCLUDE_DIR=$(shell dirname $(shell which capnp))/../include

    let prefix = {
        let output = ::std::process::Command::new("which").arg("capnp")
            .output().unwrap().stdout;
        let path = ::std::path::Path::new(::std::str::from_utf8(&output).unwrap());
        let mut path1 = path.parent().unwrap().parent().unwrap().to_path_buf();
        path1.push("include/capnp");
        path1
    };

    ::capnpc::compile(&prefix,
                      &[&prefix.clone().join("rpc.capnp"),
                        &prefix.join("rpc-twoparty.capnp")]).unwrap();
}

--- 
+++ 
@@ -1,3 +1,7 @@
+use std::str;
+use std::path::Path;
+use std::process::Command;
+
 extern crate capnpc;
 
 fn main() {
@@ -5,15 +9,18 @@
     // CAPNP_INCLUDE_DIR=$(shell dirname $(shell which capnp))/../include
 
     let prefix = {
-        let output = ::std::process::Command::new("which").arg("capnp")
-            .output().unwrap().stdout;
-        let path = ::std::path::Path::new(::std::str::from_utf8(&output).unwrap());
+        let output = Command::new("which")
+                             .arg("capnp")
+                             .output()
+                             .unwrap().stdout;
+
+        let path = Path::new(str::from_utf8(&output).unwrap());
         let mut path1 = path.parent().unwrap().parent().unwrap().to_path_buf();
         path1.push("include/capnp");
         path1
     };
 
-    ::capnpc::compile(&prefix,
-                      &[&prefix.clone().join("rpc.capnp"),
-                        &prefix.join("rpc-twoparty.capnp")]).unwrap();
+    capnpc::compile(&prefix,
+                    &[&prefix.clone().join("rpc.capnp"),
+                      &prefix.join("rpc-twoparty.capnp")]).unwrap();
 }
Use imports to shorten lines
