Skip to content

Commit

Permalink
Implement a basic Debug trait on all iterators
Browse files Browse the repository at this point in the history
  • Loading branch information
Kerollmops committed Aug 23, 2023
1 parent 7c64f0b commit ed7bf9b
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 2 deletions.
3 changes: 1 addition & 2 deletions heed/src/database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@ use std::borrow::Cow;
use std::ops::{Bound, RangeBounds};
use std::{any, fmt, marker, mem, ptr};

use types::{DecodeIgnore, LazyDecode};

use crate::cursor::MoveOperation;
use crate::iteration_method::MoveOnCurrentKeyDuplicates;
use crate::mdb::error::mdb_result;
use crate::mdb::ffi;
use crate::mdb::lmdb_flags::{AllDatabaseFlags, DatabaseFlags};
use crate::types::{DecodeIgnore, LazyDecode};
use crate::*;

/// Options and flags which can be used to configure how a [`Database`] is opened.
Expand Down
24 changes: 24 additions & 0 deletions heed/src/iterator/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,12 @@ where
}
}

impl<KC, DC, IM> fmt::Debug for RoIter<'_, KC, DC, IM> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("RoIter").finish()
}
}

/// A read-write iterator structure.
pub struct RwIter<'txn, KC, DC, IM = MoveThroughDuplicateValues> {
cursor: RwCursor<'txn>,
Expand Down Expand Up @@ -422,6 +428,12 @@ where
}
}

impl<KC, DC, IM> fmt::Debug for RwIter<'_, KC, DC, IM> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("RwIter").finish()
}
}

/// A reverse read-only iterator structure.
pub struct RoRevIter<'txn, KC, DC, IM = MoveThroughDuplicateValues> {
cursor: RoCursor<'txn>,
Expand Down Expand Up @@ -533,6 +545,12 @@ where
}
}

impl<KC, DC, IM> fmt::Debug for RoRevIter<'_, KC, DC, IM> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("RoRevIter").finish()
}
}

/// A reverse read-write iterator structure.
pub struct RwRevIter<'txn, KC, DC, IM = MoveThroughDuplicateValues> {
cursor: RwCursor<'txn>,
Expand Down Expand Up @@ -756,3 +774,9 @@ where
}
}
}

impl<KC, DC, IM> fmt::Debug for RwRevIter<'_, KC, DC, IM> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("RwRevIter").finish()
}
}
24 changes: 24 additions & 0 deletions heed/src/iterator/prefix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,12 @@ where
}
}

impl<KC, DC, IM> fmt::Debug for RoPrefix<'_, KC, DC, IM> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("RoPrefix").finish()
}
}

/// A read-write prefix iterator structure.
pub struct RwPrefix<'txn, KC, DC, IM = MoveThroughDuplicateValues> {
cursor: RwCursor<'txn>,
Expand Down Expand Up @@ -387,6 +393,12 @@ where
}
}

impl<KC, DC, IM> fmt::Debug for RwPrefix<'_, KC, DC, IM> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("RwPrefix").finish()
}
}

/// A reverse read-only prefix iterator structure.
pub struct RoRevPrefix<'txn, KC, DC, IM = MoveThroughDuplicateValues> {
cursor: RoCursor<'txn>,
Expand Down Expand Up @@ -516,6 +528,12 @@ where
}
}

impl<KC, DC, IM> fmt::Debug for RoRevPrefix<'_, KC, DC, IM> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("RoRevPrefix").finish()
}
}

/// A reverse read-write prefix iterator structure.
pub struct RwRevPrefix<'txn, KC, DC, IM = MoveThroughDuplicateValues> {
cursor: RwCursor<'txn>,
Expand Down Expand Up @@ -757,3 +775,9 @@ where
}
}
}

impl<KC, DC, IM> fmt::Debug for RwRevPrefix<'_, KC, DC, IM> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("RwRevPrefix").finish()
}
}
24 changes: 24 additions & 0 deletions heed/src/iterator/range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,12 @@ where
}
}

impl<KC, DC, IM> fmt::Debug for RoRange<'_, KC, DC, IM> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("RoRange").finish()
}
}

/// A read-write range iterator structure.
pub struct RwRange<'txn, KC, DC, IM = MoveThroughDuplicateValues> {
cursor: RwCursor<'txn>,
Expand Down Expand Up @@ -461,6 +467,12 @@ where
}
}

impl<KC, DC, IM> fmt::Debug for RwRange<'_, KC, DC, IM> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("RwRange").finish()
}
}

/// A reverse read-only range iterator structure.
pub struct RoRevRange<'txn, KC, DC, IM = MoveThroughDuplicateValues> {
cursor: RoCursor<'txn>,
Expand Down Expand Up @@ -616,6 +628,12 @@ where
}
}

impl<KC, DC, IM> fmt::Debug for RoRevRange<'_, KC, DC, IM> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("RoRevRange").finish()
}
}

/// A reverse read-write range iterator structure.
pub struct RwRevRange<'txn, KC, DC, IM = MoveThroughDuplicateValues> {
cursor: RwCursor<'txn>,
Expand Down Expand Up @@ -883,3 +901,9 @@ where
}
}
}

impl<KC, DC, IM> fmt::Debug for RwRevRange<'_, KC, DC, IM> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("RwRevRange").finish()
}
}

0 comments on commit ed7bf9b

Please sign in to comment.