
jjeffers
Hands-on Rust: Example code fails to run without crashing
Copying the example code from GitHub - thebracket/HandsOnRust: The source code that accompanies Hands-on Rust: Effective Learning through 2D Game Development and Play by Herbert Wolverson, phase by phase, and running cargo run
produces an executable that crashes with a panic.
For example, copying the entire contents of HandsOnRust/EntitiesComponentsAndSystems/playerecs/ and then building:
Finished `dev` profile [unoptimized + debuginfo] target(s) in 24.19s
Running `target/debug/playerecs`
thread 'main' panicked at library/core/src/panicking.rs:220:5:
unsafe precondition(s) violated: slice::from_raw_parts requires the pointer to be aligned and non-null, and the total size of the slice not to exceed `isize::MAX`
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread caused non-unwinding panic. aborting.
Aborted (core dumped)
When the same code is build within the repo directories, it builds and runs without an error.
I do not yet understand why this is different.
First Post!

jjeffers
I did find that if if I locked the bracket-terminal
version to 0.8.5, the example code, compiles and runs correctly and without panics.
I compared the Cargo.lock in the base directory of the HandOn...
repo and the copied example and noticed the bracket-terminal
versions were different.
Since I am new to rust, I am still trying to discern why they are different.
Popular Pragmatic topics










Other popular topics









Latest in PragProg
Latest (all)
Categories:
Popular Portals
- /elixir
- /rust
- /wasm
- /ruby
- /erlang
- /phoenix
- /keyboards
- /js
- /rails
- /python
- /security
- /go
- /swift
- /vim
- /clojure
- /java
- /haskell
- /emacs
- /svelte
- /onivim
- /typescript
- /crystal
- /c-plus-plus
- /tailwind
- /kotlin
- /gleam
- /react
- /flutter
- /elm
- /ocaml
- /vscode
- /opensuse
- /ash
- /centos
- /php
- /deepseek
- /zig
- /scala
- /html
- /debian
- /nixos
- /lisp
- /agda
- /textmate
- /sublime-text
- /react-native
- /kubuntu
- /arch-linux
- /revery
- /ubuntu
- /manjaro
- /spring
- /django
- /diversity
- /nodejs
- /lua
- /slackware
- /julia
- /c
- /neovim