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

rand 0.9 beta error - isize: SampleUniform is not satisfied #1540

Open
pendruct opened this issue Nov 27, 2024 · 2 comments
Open

rand 0.9 beta error - isize: SampleUniform is not satisfied #1540

pendruct opened this issue Nov 27, 2024 · 2 comments

Comments

@pendruct
Copy link

i used to be able to do rng.gen with isize but not anymore

@pendruct pendruct added the X-bug Type: bug report label Nov 27, 2024
@dhardy dhardy removed the X-bug Type: bug report label Nov 27, 2024
@dhardy
Copy link
Member

dhardy commented Nov 27, 2024

This is intentional: #1487.

Why do you need this?

@pendruct
Copy link
Author

pendruct commented Nov 27, 2024

oh okay! so is this a breaking change then? i didnt see it mentioned in changelog but maybe im missing something.

i am making a game with a 2d maze and i use it for my teleport function:

fn teleport_destination_node(grid: &Grid, player_row: usize) -> Option<(usize, usize)> {
  let delta = roll(-2..13);
  let dest_row = player_row.saturating_add_signed(delta).clamp(0, grid.height.saturating_sub(1));

  for col in 0..grid.width {
    if grid.node(dest_row, col).is_main {
      return Some((dest_row, col));
    }
  }

  None
}

it's not that important though so i can just refactor it. thanks for the info!

im using usize and isize because im doing indexing into 2d arrays and thats what rust asks for

was able to get around it by doing this (since you can make an isize from an i16):

let delta: isize = roll(-2i16..13i16).into();

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

No branches or pull requests

2 participants