From c0be1cb7a51f1c50e057469de94f3a3bb7dfcb64 Mon Sep 17 00:00:00 2001 From: Colin Date: Wed, 24 Feb 2021 13:00:18 -0500 Subject: [PATCH] [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 --- rust/flexbuffers/src/reader/map.rs | 2 -- rust/flexbuffers/src/reader/mod.rs | 2 +- tests/rust_usage_test/bin/flexbuffers_alloc_check.rs | 4 ++++ 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/rust/flexbuffers/src/reader/map.rs b/rust/flexbuffers/src/reader/map.rs index b0accacc8..7d6ada8ab 100644 --- a/rust/flexbuffers/src/reader/map.rs +++ b/rust/flexbuffers/src/reader/map.rs @@ -71,8 +71,6 @@ impl std::fmt::Debug for MapReader { impl MapReader { /// Returns the number of key/value pairs are in the map. pub fn len(&self) -> usize { - let thing = self.clone(); - println!("{:?}", &thing); self.length } diff --git a/rust/flexbuffers/src/reader/mod.rs b/rust/flexbuffers/src/reader/mod.rs index cac46341e..311f91d37 100644 --- a/rust/flexbuffers/src/reader/mod.rs +++ b/rust/flexbuffers/src/reader/mod.rs @@ -306,7 +306,7 @@ impl Reader { #[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(&self) -> Result<&[T], Error> { if self.flexbuffer_type().typed_vector_type() != T::VECTOR_TYPE.typed_vector_type() { diff --git a/tests/rust_usage_test/bin/flexbuffers_alloc_check.rs b/tests/rust_usage_test/bin/flexbuffers_alloc_check.rs index 847d7c6ad..a921af7fb 100644 --- a/tests/rust_usage_test/bin/flexbuffers_alloc_check.rs +++ b/tests/rust_usage_test/bin/flexbuffers_alloc_check.rs @@ -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");