4.2.2 数组类型
02-数组类型 — Comprehensive Rust
1分钟内可阅读完
译文 · 基于 Comprehensive Rust
原文链接: https://google.github.io/comprehensive-rust/android/aidl/types/arrays.html
4.2.2 数组类型
数组类型(T[]、byte[] 与 List<T>)会根据它们在函数签名中的用法,翻译成合适的 Rust 数组类型:
| 位置 | Rust 类型 |
|---|---|
in 参数 | &[T] |
out/inout 参数 | &mut Vec<T> |
| 返回值 | Vec<T> |
- 在 Android 13 或更高版本中,支持固定大小数组,即
T[N]变为[T; N]。固定大小数组可以有多个维度(例如int[3][4])。在 Java 后端,固定大小数组表示为数组类型。- parcelable 字段中的数组总是翻译为
Vec<T>。