about summary refs log tree commit diff
path: root/src/libstd/logging.rs
diff options
context:
space:
mode:
authorMarvin Löbel <loebel.marvin@gmail.com>2013-09-14 19:37:45 +0200
committerMarvin Löbel <loebel.marvin@gmail.com>2013-09-16 16:57:50 +0200
commit76c3e8a38cea2fe6342d83158c267e57a6b1f53f (patch)
treedb7c6ca84a3e769ed40343411ecf43f369883418 /src/libstd/logging.rs
parent3e1803f3af1adc1b2e5595650f6920f40bbedc2e (diff)
Add an SendStr type
A SendStr is a string that can hold either a ~str or a &'static str.
This can be useful as an optimization when an allocation is sometimes needed but the common case is statically known.

Possible use cases include Maps with both static and owned keys, or propagating error messages across task boundaries.

SendStr implements most basic traits in a way that hides the fact that it is an enum; in particular things like order and equality are only determined by the content of the wrapped strings.

Replaced std::rt:logging::SendableString with SendStr
Added tests for using an SendStr as key in Hash- and Treemaps
Diffstat (limited to 'src/libstd/logging.rs')
-rw-r--r--src/libstd/logging.rs7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/libstd/logging.rs b/src/libstd/logging.rs
index db5edc2009e..b39b3102a34 100644
--- a/src/libstd/logging.rs
+++ b/src/libstd/logging.rs
@@ -13,7 +13,8 @@
 use option::*;
 use os;
 use rt;
-use rt::logging::{Logger, StdErrLogger, OwnedString};
+use rt::logging::{Logger, StdErrLogger};
+use send_str::SendStrOwned;
 
 /// Turns on logging to stdout globally
 pub fn console_on() {
@@ -56,12 +57,12 @@ fn newsched_log_str(msg: ~str) {
         match optional_task {
             Some(local) => {
                 // Use the available logger
-                (*local).logger.log(OwnedString(msg));
+                (*local).logger.log(SendStrOwned(msg));
             }
             None => {
                 // There is no logger anywhere, just write to stderr
                 let mut logger = StdErrLogger;
-                logger.log(OwnedString(msg));
+                logger.log(SendStrOwned(msg));
             }
         }
     }