Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
mijoharas opened this issue Apr 10, 2014 · 2 comments
Closed

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

mijoharas opened this issue Apr 10, 2014 · 2 comments

Comments

@mijoharas
Copy link

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.)

@sfackler
Copy link
Member

@mijoharas
Copy link
Author

ahhh, brilliant, thank you. Can anyone suggest the correct syntax for using readline with rust? (my attempted correction simply exits without doing anything, is this incorrect use of rust syntax or incorrect use of the readline library? (unfortunately I'm new to both.) original code is right here

bors added a commit that referenced this issue Apr 12, 2014
Using some strategically-placed `#` markers most of the examples are testable
(and their contents are nontrivial).

Closes #13445
notriddle pushed a commit to notriddle/rust that referenced this issue Nov 10, 2022
fix) update broken links in guide.md

Hi, I Just fixed some broken links in `guide.md`.

In most cases, it is not connected by an old version (expecially `guide-2019-01`) of the link, so I made some modifications.

Thanks for your time :)
flip1995 pushed a commit to flip1995/rust that referenced this issue Oct 3, 2024
`invalid_null_ptr_usage`: fix false positives for `std::ptr::slice_from_raw_parts` functions

fixes rust-lang#13445
changelog: [`invalid_null_ptr_usage`]: fix false positives for `std::ptr::slice_from_raw_parts` functions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants