Skip to content

Change old documentation that uses deprecated "do" syntax #13445

Closed
@mijoharas

Description

@mijoharas

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions