Consider T alignment for empty rust::Slice

This commit is contained in:
David Tolnay 2020-11-25 20:23:10 -08:00
parent 71c7b45e4f
commit 7b16a39a02
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82

View File

@ -390,7 +390,7 @@ inline size_t Str::length() const noexcept { return this->len; }
#ifndef CXXBRIDGE1_RUST_SLICE
#define CXXBRIDGE1_RUST_SLICE
template <typename T>
Slice<T>::Slice() noexcept : ptr(reinterpret_cast<T *>(this)), len(0) {}
Slice<T>::Slice() noexcept : ptr(reinterpret_cast<T *>(alignof(T))), len(0) {}
template <typename T>
Slice<T>::Slice(T *s, size_t count) noexcept : ptr(s), len(count) {}