message: Add pub CommandExecutor::instance() and make global variable private.
diff: @@ -18,7 +18,7 @@ use std::error;
  use std::sync::mpsc::{Sender, channel};
  use std::rc::Rc;
  use std::thread;
  -use std::sync::Mutex;
  +use std::sync::{Mutex, MutexGuard};
  pub enum Command {
  Exit,
  @@ -40,15 +40,19 @@ pub struct CommandExecutor {
  ///
  /// {
  /// ...
  -/// let ref ce: CommandExecutor = *COMMAND_EXECUTOR.lock().unwrap(); <- lock +
  +/// let ref ce: CommandExecutor = *CommandExecutor::instance(); <- lock +
  /// ce.send(Command::Exit); |
  /// ... |
  /// } <- unlock +
  lazy_static! {
  - pub static ref COMMAND_EXECUTOR: Mutex<CommandExecutor> = Mutex::new(CommandExecutor::new());
  + static ref COMMAND_EXECUTOR: Mutex<CommandExecutor> = Mutex::new(CommandExecutor::new());
  }
  impl CommandExecutor {
  + pub fn instance<'mutex>() -> MutexGuard<'mutex, CommandExecutor> {
  + COMMAND_EXECUTOR.lock().unwrap()
  + }
  +
  fn new() -> CommandExecutor {
  let (sender, receiver) = channel();
  @@ -137,4 +141,11 @@ mod tests {
  drop_test();
  assert!(true, "No crashes on CommandExecutor::drop");
  }
  +
  + #[test]
  + fn command_executor_can_get_instance() {
  + let ref command_executor: CommandExecutor = *CommandExecutor::instance();
  + // Deadlock if another one instance will be requested (try to uncomment the next line)
  + // let ref other_ce: CommandExecutor = *CommandExecutor::instance();
  + }
  }
  \ No newline at end of file
  