File tree Expand file tree Collapse file tree 1 file changed +12
-3
lines changed
Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -321,9 +321,6 @@ impl<T> Buffer<T> {
321321 if !begin_byte. is_multiple_of ( * alignment) {
322322 vortex_panic ! ( "range start must be aligned to {alignment:?}" ) ;
323323 }
324- if !end_byte. is_multiple_of ( * alignment) {
325- vortex_panic ! ( "range end must be aligned to {alignment:?}" ) ;
326- }
327324 if !alignment. is_aligned_to ( Alignment :: of :: < T > ( ) ) {
328325 vortex_panic ! ( "Slice alignment must at least align to type T" )
329326 }
@@ -744,4 +741,16 @@ mod test {
744741 assert ! ( buff. is_aligned( Alignment :: of:: <i32 >( ) ) ) ;
745742 assert_eq ! ( vec, buff) ;
746743 }
744+
745+ #[ test]
746+ fn test_slice_unaligned_end_pos ( ) {
747+ let data = vec ! [ 0u8 ; 2 ] ;
748+ // Overalign the u8 vector.
749+ let aligned_buffer = Buffer :: copy_from_aligned ( & data, Alignment :: new ( 8 ) ) ;
750+ // Previously, `Buffer::slice` incorrectly asserted that the end position
751+ // must be aligned. That assertion has been removed such that the end
752+ // position can be arbitrary and only the beginning of the slice needs
753+ // to be aligned.
754+ aligned_buffer. slice ( 0 ..1 ) ;
755+ }
747756}
You can’t perform that action at this time.
0 commit comments