[rust] Remove debug code (#6475)

* Remove debug code

This was added for testing in the recent genericize PR for flexbuffer Reader.

* Added alloc tests -> MapReader::{is_empty, index_key, len}

* Added , accessible through Deref to deprecation warning
This commit is contained in:
Colin
2021-02-24 13:00:18 -05:00
committed by GitHub
parent 8cccdfba53
commit c0be1cb7a5
3 changed files with 5 additions and 3 deletions

View File

@@ -71,8 +71,6 @@ impl<B: Buffer> std::fmt::Debug for MapReader<B> {
impl<B: Buffer> MapReader<B> {
/// Returns the number of key/value pairs are in the map.
pub fn len(&self) -> usize {
let thing = self.clone();
println!("{:?}", &thing);
self.length
}

View File

@@ -306,7 +306,7 @@ impl<B: Buffer> Reader<B> {
#[cfg(target_endian = "little")]
#[deprecated(
since = "0.3.0",
note = "This function is unsafe - if this functionality is needed it can be added separately via the `buffer` function."
note = "This function is unsafe - if this functionality is needed use `Reader::buffer::align_to`"
)]
pub fn get_slice<T: ReadLE>(&self) -> Result<&[T], Error> {
if self.flexbuffer_type().typed_vector_type() != T::VECTOR_TYPE.typed_vector_type() {

View File

@@ -70,6 +70,10 @@ fn make_monster(mut monster: MapBuilder) {
fn validate_monster(flexbuffer: &[u8]) {
let r = Reader::get_root(flexbuffer).unwrap().as_map();
assert!(!r.is_empty());
assert!(r.index_key("not_a_field").is_none());
assert_eq!(r.len(), 7);
assert_eq!(r.idx("type").as_str(), "great orc");
assert_eq!(r.idx("age").as_u8(), 100);
assert_eq!(r.idx("name").as_str(), "Mr. Orc");