Skip to content

Commit

Permalink
fix: return ValueRefs from Sequence::extract_sequence
Browse files Browse the repository at this point in the history
  • Loading branch information
decahedron1 committed Dec 27, 2024
1 parent 73eb1d8 commit 3d7278f
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/value/impl_sequence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ impl<Type: SequenceValueTypeMarker + Sized> Value<Type> {
pub fn try_extract_sequence<OtherType: ValueTypeMarker + DowncastableTarget + Debug + Sized>(
&self,
allocator: &Allocator
) -> Result<Vec<Value<OtherType>>> {
) -> Result<Vec<ValueRef<'_, OtherType>>> {
match self.dtype() {
ValueType::Sequence(_) => {
let mut len = 0;
Expand All @@ -85,7 +85,9 @@ impl<Type: SequenceValueTypeMarker + Sized> Value<Type> {
let mut value_ptr = ptr::null_mut();
ortsys![unsafe GetValue(self.ptr(), i as _, allocator.ptr().cast_mut(), &mut value_ptr)?; nonNull(value_ptr)];

let value = unsafe { Value::from_ptr(NonNull::new_unchecked(value_ptr), None) };
let mut value = ValueRef::new(unsafe { Value::from_ptr(NonNull::new_unchecked(value_ptr), None) });
value.upgradable = false;

let value_type = value.dtype();
if !OtherType::can_downcast(value.dtype()) {
return Err(Error::new_with_code(
Expand Down Expand Up @@ -149,7 +151,7 @@ impl<T: ValueTypeMarker + DowncastableTarget + Debug + Sized + 'static> Value<Se
}

impl<T: ValueTypeMarker + DowncastableTarget + Debug + Sized> Value<SequenceValueType<T>> {
pub fn extract_sequence(&self, allocator: &Allocator) -> Vec<Value<T>> {
pub fn extract_sequence(&self, allocator: &Allocator) -> Vec<ValueRef<'_, T>> {
self.try_extract_sequence(allocator).expect("Failed to extract sequence")
}

Expand Down

0 comments on commit 3d7278f

Please sign in to comment.