Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bdaa579

Browse files
committed
feat: Add Display Implementation for NodeIndex<Ix>
and EdgeIndex<Ix> where Ix: Display.
1 parent 1629035 commit bdaa579

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

src/graph_impl/mod.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,12 @@ impl<Ix: IndexType> NodeIndex<Ix> {
125125
}
126126
}
127127

128+
impl<Ix: fmt::Display> fmt::Display for NodeIndex<Ix> {
129+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
130+
write!(f, "NodeIndex({})", self.0)
131+
}
132+
}
133+
128134
unsafe impl<Ix: IndexType> IndexType for NodeIndex<Ix> {
129135
fn index(&self) -> usize {
130136
self.0.index()
@@ -192,6 +198,12 @@ impl<Ix: IndexType> From<Ix> for EdgeIndex<Ix> {
192198
}
193199
}
194200

201+
impl<Ix: fmt::Display> fmt::Display for EdgeIndex<Ix> {
202+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
203+
write!(f, "EdgeIndex({})", self.0)
204+
}
205+
}
206+
195207
impl<Ix: fmt::Debug> fmt::Debug for EdgeIndex<Ix> {
196208
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
197209
write!(f, "EdgeIndex({:?})", self.0)

0 commit comments

Comments
 (0)