diff --git a/communication/examples/comm_hello.rs b/communication/examples/comm_hello.rs index 2b65efd01..73c0c09ce 100644 --- a/communication/examples/comm_hello.rs +++ b/communication/examples/comm_hello.rs @@ -23,7 +23,7 @@ impl Bytesable for Message { fn main() { // extract the configuration from user-supplied arguments, initialize the computation. - let config = timely_communication::Config::from_args(std::env::args()).unwrap(); + let (config, _free) = timely_communication::Config::from_args(std::env::args()).unwrap(); let guards = timely_communication::initialize(config, |mut allocator| { println!("worker {} of {} started", allocator.index(), allocator.peers()); diff --git a/communication/src/initialize.rs b/communication/src/initialize.rs index 7592eb67e..5f92aff6f 100644 --- a/communication/src/initialize.rs +++ b/communication/src/initialize.rs @@ -142,12 +142,13 @@ impl Config { /// /// This method is only available if the `getopts` feature is enabled, which /// it is by default. + /// The `Ok` variant returns the free command-line arguments as well as the config. #[cfg(feature = "getopts")] - pub fn from_args>(args: I) -> Result { + pub fn from_args>(args: I) -> Result<(Config, Vec), String> { let mut opts = getopts::Options::new(); Config::install_options(&mut opts); let matches = opts.parse(args).map_err(|e| e.to_string())?; - Config::from_matches(&matches) + Config::from_matches(&matches).map(|c| (c, matches.free)) } /// Attempts to assemble the described communication infrastructure. @@ -224,7 +225,7 @@ impl Config { /// } /// /// // extract the configuration from user-supplied arguments, initialize the computation. -/// let config = timely_communication::Config::from_args(std::env::args()).unwrap(); +/// let (config, _free) = timely_communication::Config::from_args(std::env::args()).unwrap(); /// let guards = timely_communication::initialize(config, |mut allocator| { /// /// println!("worker {} of {} started", allocator.index(), allocator.peers()); @@ -317,7 +318,7 @@ pub fn initializeT+Send+Sync+'static>( /// } /// /// // extract the configuration from user-supplied arguments, initialize the computation. -/// let config = timely_communication::Config::from_args(std::env::args()).unwrap(); +/// let (config, _free) = timely_communication::Config::from_args(std::env::args()).unwrap(); /// let guards = timely_communication::initialize(config, |mut allocator| { /// /// println!("worker {} of {} started", allocator.index(), allocator.peers()); diff --git a/communication/src/lib.rs b/communication/src/lib.rs index d58e4860d..0f5288674 100644 --- a/communication/src/lib.rs +++ b/communication/src/lib.rs @@ -38,7 +38,7 @@ //! } //! //! // extract the configuration from user-supplied arguments, initialize the computation. -//! let config = timely_communication::Config::from_args(std::env::args()).unwrap(); +//! let (config, _free) = timely_communication::Config::from_args(std::env::args()).unwrap(); //! let guards = timely_communication::initialize(config, |mut allocator| { //! //! println!("worker {} of {} started", allocator.index(), allocator.peers()); diff --git a/mdbook/src/chapter_5/chapter_5_1.md b/mdbook/src/chapter_5/chapter_5_1.md index 6110ff570..33527698e 100644 --- a/mdbook/src/chapter_5/chapter_5_1.md +++ b/mdbook/src/chapter_5/chapter_5_1.md @@ -35,7 +35,7 @@ impl Bytesable for Message { fn main() { // extract the configuration from user-supplied arguments, initialize the computation. - let config = timely_communication::Config::from_args(std::env::args()).unwrap(); + let (config, _free) = timely_communication::Config::from_args(std::env::args()).unwrap(); let guards = timely_communication::initialize(config, |mut allocator| { println!("worker {} of {} started", allocator.index(), allocator.peers());