From 830ac37ca2484422bb90ec3e39b8ee47d08dc1be Mon Sep 17 00:00:00 2001 From: blake2-ppc Date: Sat, 14 Sep 2013 04:07:43 +0200 Subject: std::logging: Use a more specific enum than Either --- src/libstd/rt/logging.rs | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'src/libstd/rt') diff --git a/src/libstd/rt/logging.rs b/src/libstd/rt/logging.rs index 0dd096b5bf3..d0bbf5c0506 100644 --- a/src/libstd/rt/logging.rs +++ b/src/libstd/rt/logging.rs @@ -7,7 +7,6 @@ // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. -use either::*; use libc::{uintptr_t, exit, STDERR_FILENO}; use option::{Some, None, Option}; use rt::util::dumb_println; @@ -168,14 +167,20 @@ fn update_log_settings(crate_map: *u8, settings: ~str) { } } +/// Represent a string with `Send` bound. +pub enum SendableString { + OwnedString(~str), + StaticString(&'static str) +} + pub trait Logger { - fn log(&mut self, msg: Either<~str, &'static str>); + fn log(&mut self, msg: SendableString); } pub struct StdErrLogger; impl Logger for StdErrLogger { - fn log(&mut self, msg: Either<~str, &'static str>) { + fn log(&mut self, msg: SendableString) { use io::{Writer, WriterUtil}; if !should_log_console() { @@ -183,14 +188,11 @@ impl Logger for StdErrLogger { } let s: &str = match msg { - Left(ref s) => { - let s: &str = *s; - s - } - Right(ref s) => { - let s: &str = *s; - s - } + OwnedString(ref s) => { + let slc: &str = *s; + slc + }, + StaticString(s) => s, }; // Truncate the string -- cgit 1.4.1-3-g733a5