I was reading some code, and I noticed that PointerValue wraps Value, which wraps LLVMValueRef, which is a type alias for *mut llvm_sys::LLVMValue. So I was thinking that perhaps it would make sense to instead use NonNull<LLVMValue> (or other relevant pointer type) in these places where non-nullable pointers are used.
Then these types could have repr(transparent), which would guarantee that they have the niche optimization that NonNull has, allowing T to be the same size as Option<T>, which is a very useful memory optimization.
I'm going to get started on this PR today. I just wanted to make an issue for it since there's a rule that pull requests need to be related to an issue.
I was reading some code, and I noticed that
PointerValuewrapsValue, which wrapsLLVMValueRef, which is a type alias for*mut llvm_sys::LLVMValue. So I was thinking that perhaps it would make sense to instead useNonNull<LLVMValue>(or other relevant pointer type) in these places where non-nullable pointers are used.Then these types could have
repr(transparent), which would guarantee that they have the niche optimization that NonNull has, allowingTto be the same size asOption<T>, which is a very useful memory optimization.I'm going to get started on this PR today. I just wanted to make an issue for it since there's a rule that pull requests need to be related to an issue.