rust-lang / rust-lang/rust-by-example

is the safe division example safe?

Open
#1,197 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Handlebars
Stars
8.1k
Forks
1.6k
PR merge metrics
No merged PRs in 30d

Description

This Rust newb was browsing the nice Rust By Example but was surprised to see the Safe Division example under Option. It only checks for /0, but what about -2^31/-1 ? I don’t know what rust does but you cannot represent the result in 32-bit signed int so it should check that too.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Locate the Safe Division example under the Option section and first check how Rust handles -2^31/-1 in the example's integer type. Confirm whether the example's claim of safe division is accurate, then update the example or its explanation so the overflow case is correctly handled or documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
documentation
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.