Skip to content

Treat raw pointers with more respect #76

Open
@hawkw

Description

@hawkw

I think there are at least a few cases where we can work on refactoring code that uses raw pointers to be somewhat more idiomatic:

  • where can raw pointers be replaced with ptr::Unique<T>s?
    • We already use Unique in some cases
    • I think there might be more uses of raw pointers that can be replaced with Unique.
  • where can pointer math be replaced with pointer.offset()?
    • this is considered more idiomatic
    • has less ugly casts/can be less wordy
  • where can coercing raw pointers to references be replaced with pointer.as_ref() or pointer.as_mut()?
    • these functions can still return references to uninitialised memory, but they're more null-safe (allow us to handle null pointers Optionally)
    • fewer ugly casts/transmutes
  • where can mem::transmute-ting a reference into a raw pointer be replaced with &*?
    • this is more idiomatic

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind/refactorKind: this issue describes refactoring or code quality improvement.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions