diff options
| author | Marvin Löbel <loebel.marvin@gmail.com> | 2013-09-14 19:37:45 +0200 |
|---|---|---|
| committer | Marvin Löbel <loebel.marvin@gmail.com> | 2013-09-16 16:57:50 +0200 |
| commit | 76c3e8a38cea2fe6342d83158c267e57a6b1f53f (patch) | |
| tree | db7c6ca84a3e769ed40343411ecf43f369883418 /src/libstd/sys.rs | |
| parent | 3e1803f3af1adc1b2e5595650f6920f40bbedc2e (diff) | |
| download | rust-76c3e8a38cea2fe6342d83158c267e57a6b1f53f.tar.gz rust-76c3e8a38cea2fe6342d83158c267e57a6b1f53f.zip | |
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/sys.rs')
| -rw-r--r-- | src/libstd/sys.rs | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/libstd/sys.rs b/src/libstd/sys.rs index f7f7fef6fa0..3d35de0f898 100644 --- a/src/libstd/sys.rs +++ b/src/libstd/sys.rs @@ -140,7 +140,8 @@ pub fn begin_unwind_(msg: *c_char, file: *c_char, line: size_t) -> ! { use rt::in_green_task_context; use rt::task::Task; use rt::local::Local; - use rt::logging::{Logger, OwnedString}; + use rt::logging::Logger; + use send_str::SendStrOwned; use str::Str; unsafe { @@ -163,7 +164,7 @@ pub fn begin_unwind_(msg: *c_char, file: *c_char, line: size_t) -> ! { msg, file, line as int) }; - task.logger.log(OwnedString(msg)); + task.logger.log(SendStrOwned(msg)); } } else { rterrln!("failed in non-task context at '%s', %s:%i", |
