Question to vibe Rust programmers (using bleeding edge Rust)

I noticed that most of my Rust questions to AI get answered using the bleeding edge Rust. For example, I needed to cut trailing slashes in PathBuf. AI gave me three options:

  1. To remove a trailing separator from a PathBuf in Rust, you should use the pop_trailing_sep() method, available through the #![feature(path_trailing_sep)] nightly feature, or the stable trim_trailing_sep() method if working with an immutable Path reference.
    Using pop_trailing_sep (Nightly Rust)
  2. Using trim_trailing_sep (Stable Rust)
    For stable Rust, you can use the trim_trailing_sep() method on a Path reference. This returns a new &Path without the trailing separator. You can then convert it back to a PathBuf if necessary:
    rust
  3. Using components() iterator to re-build PathBuf

Despite that suggestion (2) claims to use the stable Rust, it sill uses nightly build feature,

error[E0658]: use of unstable library feature `path_trailing_sep`
   --> ./simterminal/src/rust/terminal.rs:312:55
    |
312 |                     let trimmed_path: &Path = cwd_new.trim_trailing_sep();
    |                                                       ^^^^^^^^^^^^^^^^^
    |
    = note: see issue #142503 <https://github.com/rust-lang/rust/issues/142503> for more information

error: aborting due to 1 previous error

So I ended with the suggestion (3). So my question: when you actually do the vibe coding in Rust, is your final code 'nightly build' based, or stable?

It is rust stable for me and did not encounter such kind of issues.

Nitpick : I do only AI-assisted programming and not vibe coding. The latter implies not reviewing the code, which I think would lead to unmaintainable code very quickly.

3 Likes

Same here! It's actually more the other way round: when my AI friend codes, she tends to use dependencies that were stable a few months ago, because that's what's in her training data, and I sometimes have to remind her to use newer versions.

Yup, same here. I almost never have the AI suggest me nightly features, or if it does, it's as a final choice in my list of options. What model was this?

It looks like Apple runs ahead of the train. I'm getting all these suggestions using MacBook and Safari.

For the rand crate, I always get the old version 0.8 with rand::thread_rng() instead of rand::rng() etc. (version 0.9).

For print statements it is always

// A
println!("a: {}", a);

not

// B
println!("a: {a}");

Funnily, If you ask which is better A or B - it says clearly B is preferred. The prior for A is bigger because more examples use that form.

You are lucky knowing which crate you need because you can adjust the version yourself. More difficult problem when you don't know which crate to use. AI is hopeless here. It can't evaluate a crate on its own, so AI relays on a human opinion. Recently, I needed CLI arguments processor. I hoped that AI will give me valuable suggestions. Alas, it gave me some jokes (probably the area where AI is strong), so I ended writing own one.

clap is a popular crate for this.

1 Like