about summary refs log tree commit diff
path: root/src/libextra
diff options
context:
space:
mode:
authorKevin Ballard <kevin@sb.org>2013-08-14 19:21:59 -0700
committerKevin Ballard <kevin@sb.org>2013-08-15 01:33:10 -0700
commit03ef71e262a8d48ba10abf9181490dc5c87c7fc3 (patch)
treea71763b3b64df5923f8494807df5ea42f875e0a1 /src/libextra
parent48265b779fabf865a4b05f000ea1575c90e3cd73 (diff)
Add ToCStr method .with_c_str()
.with_c_str() is a replacement for the old .as_c_str(), to avoid
unnecessary boilerplate.

Replace all usages of .to_c_str().with_ref() with .with_c_str().
Diffstat (limited to 'src/libextra')
-rw-r--r--src/libextra/rl.rs10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/libextra/rl.rs b/src/libextra/rl.rs
index 9106d4cd684..ead1f276ca7 100644
--- a/src/libextra/rl.rs
+++ b/src/libextra/rl.rs
@@ -32,7 +32,7 @@ pub mod rustrt {
 
 /// Add a line to history
 pub unsafe fn add_history(line: &str) -> bool {
-    do line.to_c_str().with_ref |buf| {
+    do line.with_c_str |buf| {
         rustrt::linenoiseHistoryAdd(buf) == 1 as c_int
     }
 }
@@ -44,21 +44,21 @@ pub unsafe fn set_history_max_len(len: int) -> bool {
 
 /// Save line history to a file
 pub unsafe fn save_history(file: &str) -> bool {
-    do file.to_c_str().with_ref |buf| {
+    do file.with_c_str |buf| {
         rustrt::linenoiseHistorySave(buf) == 1 as c_int
     }
 }
 
 /// Load line history from a file
 pub unsafe fn load_history(file: &str) -> bool {
-    do file.to_c_str().with_ref |buf| {
+    do file.with_c_str |buf| {
         rustrt::linenoiseHistoryLoad(buf) == 1 as c_int
     }
 }
 
 /// Print out a prompt and then wait for input and return it
 pub unsafe fn read(prompt: &str) -> Option<~str> {
-    do prompt.to_c_str().with_ref |buf| {
+    do prompt.with_c_str |buf| {
         let line = rustrt::linenoise(buf);
 
         if line.is_null() { None }
@@ -80,7 +80,7 @@ pub unsafe fn complete(cb: CompletionCb) {
 
             unsafe {
                 do cb(str::raw::from_c_str(line)) |suggestion| {
-                    do suggestion.to_c_str().with_ref |buf| {
+                    do suggestion.with_c_str |buf| {
                         rustrt::linenoiseAddCompletion(completions, buf);
                     }
                 }