Closed
Description
in the rust documentation for 0.10 in the second block
use std::libc;
use std::ptr;
#[link(name = "readline")]
extern {
static mut rl_prompt: *libc::c_char;
}
fn main() {
do "[my-awesome-shell] $".as_c_str |buf| {
unsafe { rl_prompt = buf; }
// get a line, process it
unsafe { rl_prompt = ptr::null(); }
}
}
This will not compile as it uses the old do
syntax that has been deprecated. Could we update it to the current syntax?
my attempt got it to compile but did not enable me to use readline (by trying to simply copy the code).
use std::libc;
use std::ptr;
#[link(name = "readline")]
extern {
static mut rl_prompt: *libc::c_char;
}
fn main() {
"[my-awesome-shell] $".with_c_str(|buf| {
unsafe { rl_prompt = buf; }
// get a line, process it
unsafe { rl_prompt = ptr::null(); }
})
}
Does anyone have a suggestion on how to make this work and whether there's a github repo for the documentation to send a PR to? (I couldn't find one.)
Metadata
Metadata
Assignees
Labels
No labels