mirror of
https://github.com/storytold/storyteller-bevy.git
synced 2026-10-28 08:58:07 +00:00
Fix type mismatch
This commit is contained in:
+17
-1
@@ -1,7 +1,7 @@
|
|||||||
#![allow(dead_code, missing_docs)]
|
#![allow(dead_code, missing_docs)]
|
||||||
|
|
||||||
use crate::Channel;
|
use crate::Channel;
|
||||||
use bstr::{BStr, BString, ByteSlice};
|
use bstr::{BStr, BString, ByteSlice, Utf8Error};
|
||||||
use smallvec::SmallVec;
|
use smallvec::SmallVec;
|
||||||
use std::{
|
use std::{
|
||||||
cmp::{Ordering, PartialEq, PartialOrd},
|
cmp::{Ordering, PartialEq, PartialOrd},
|
||||||
@@ -62,6 +62,16 @@ impl JointData {
|
|||||||
name.as_bytes()
|
name.as_bytes()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub(crate) fn name_str(&self) -> Result<&str, Utf8Error> {
|
||||||
|
let name = match *self {
|
||||||
|
JointData::Root { ref name, .. } => name,
|
||||||
|
JointData::Child { ref name, .. } => name,
|
||||||
|
};
|
||||||
|
|
||||||
|
name.as_str()
|
||||||
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub(crate) const fn offset(&self) -> &Offset {
|
pub(crate) const fn offset(&self) -> &Offset {
|
||||||
match *self {
|
match *self {
|
||||||
@@ -213,9 +223,15 @@ pub(crate) type JointNameInner = SmallVec<[u8; mem::size_of::<String>()]>;
|
|||||||
pub(crate) struct JointName(pub(crate) JointNameInner);
|
pub(crate) struct JointName(pub(crate) JointNameInner);
|
||||||
|
|
||||||
impl JointName {
|
impl JointName {
|
||||||
|
#[inline]
|
||||||
pub(crate) fn as_bytes(&self) -> &[u8] {
|
pub(crate) fn as_bytes(&self) -> &[u8] {
|
||||||
self.as_ref()
|
self.as_ref()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub(crate) fn as_str(&self) -> Result<&str, Utf8Error> {
|
||||||
|
self.as_bytes().to_str()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Deref for JointName {
|
impl Deref for JointName {
|
||||||
|
|||||||
@@ -535,7 +535,11 @@ mod tests {
|
|||||||
channels: &[ChannelType],
|
channels: &[ChannelType],
|
||||||
end_site: O,
|
end_site: O,
|
||||||
) {
|
) {
|
||||||
assert_eq!(joint.name(), expected_name);
|
let name = match joint.name_str() {
|
||||||
|
Ok(name) => name,
|
||||||
|
Err(err) => panic!("{err}"),
|
||||||
|
};
|
||||||
|
assert_eq!(name, expected_name);
|
||||||
assert_eq!(*joint.offset(), expected_offset);
|
assert_eq!(*joint.offset(), expected_offset);
|
||||||
for (chan, expected_chan) in joint
|
for (chan, expected_chan) in joint
|
||||||
.channels()
|
.channels()
|
||||||
|
|||||||
Reference in New Issue
Block a user