Skip to content

[Rust] Borrow BigInt, DLDataType and DLDevice in place with downcast_ref - #936

Merged
spectrometerHBH merged 2 commits into
apache:mainfrom
tqchen:downcast-ref-cell-types
Nov 6, 2026
Merged

spectrometerHBH merged 2 commits into
apache:mainfrom
tqchen:downcast-ref-cell-types

Conversation

@tqchen

@tqchen tqchen commented Nov 6, 2026

Copy link
Copy Markdown
Member

downcast_ref and Array indexing now borrow DLDataType, DLDevice and BigInt in place, as they do i64 and f64. DLDataType and DLDevice are stored in the cell's union as themselves, and a BigInt is a whole cell, like Any.

let dtype: &DLDataType = value.downcast_ref::<DLDataType>().unwrap();
let n: &BigInt = value.downcast_ref::<BigInt>().unwrap();

These two commits were pushed to #935 after it was reviewed and did not land with it.

@spectrometerHBH
spectrometerHBH merged commit d37f62d into apache:main Nov 6, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants