Skip to content

Instantly share code, notes, and snippets.

@Hoverbear
Last active December 23, 2015 15:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Hoverbear/6655412 to your computer and use it in GitHub Desktop.
Save Hoverbear/6655412 to your computer and use it in GitHub Desktop.
use std::os;
use std::rt::io::net::{ip,udp};
// Usage Notes
static USAGE: &'static str = "Usage: ./sws <port> <folder>";
// The options available to the program.
struct Options {
port: ip::SocketAddr,
directory: ~str
}
// Initialization Code.
fn main() {
// Get the program options.
let args : ~[~str] = os::args();
if (args.len() != 3) { // Error if we don't have enough.
fail!(USAGE);
}
println!("{:?}",args);
let options = Options {
port: match args[1] {
Some(x) => FromStr::from_str(x),
None => fail!("Couldn't parse port")
},
directory: args[2]
};
// Set up a socket.
}
@Hoverbear
Copy link
Author

➜  Desktop  rust run sws.rs
sws.rs:23:6: 23:13 error: mismatched types: expected `~str` but found an enum or structure pattern
sws.rs:23       Some(x) => FromStr::from_str(x),
                ^~~~~~~
sws.rs:24:6: 24:10 error: mismatched types: expected `~str` but found an enum or structure pattern
sws.rs:24       None => fail!("Couldn't parse port")
                ^~~~
sws.rs:22:10: 25:5 error: mismatched types: expected `std::rt::io::net::ip::SocketAddr` but found `std::option::Option<<V91>>` (expected struct std::rt::io::net::ip::SocketAddr but found enum std::option::Option)
sws.rs:22     port: match args[1] {
sws.rs:23       Some(x) => FromStr::from_str(x),
sws.rs:24       None => fail!("Couldn't parse port")
sws.rs:25     },
sws.rs:23:17: 23:34 error: cannot determine a type for this bounded type parameter: unconstrained type
sws.rs:23       Some(x) => FromStr::from_str(x),

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment