<分区>
我有这样的架构:
table BinaryValue {
buf: [ubyte];
}
table MyValue {
...[some other fields]
my_binary_value: BinaryValue;
}
当我尝试像这样访问 my_binary_value
时,我收到此消息:
'索引 3136 超出了长度为 140 的切片的范围'
我用来访问的代码是:
let my_binary_value = match op.my_binary_value() {
Some(binary_value) => match binary_value.buf() {
Some(buf) => {
println!(
"buf: {:?}",
buf
);
buf
}
None => {
return Err(format_err!("The my_binary_value is required."));
}
},
None => {
return Err(format_err!(
"The binary_value is required"
));
}
};
它在这条线上发生 panic :
let my_binary_value = match op.my_binary_value() {
我打印出 binary_value 的值,它看起来没问题(截断):
Some(BinaryValue { _tab: Table { buf: [20, 0, 0, 0, 48, 52, ...], loc: 60 } })
这里是生成的 FlatBuffers 代码:
#[inline]
pub fn buf(&self) -> Option<&'a [u8]> {
self._tab.get::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'a, u8>>>(BinaryValue::VT_BUF, None).map(|v| v.safe_slice())
}
知道我做错了什么吗?