Skip to content

Commit 688bc66

Browse files
committed
Implemented binary search for column
1 parent b6594fd commit 688bc66

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

src/docs.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ impl ColumnDoc {
2121
/// - name: `String` - the name of the column
2222
/// - doc: `Option<String>` the comment for the column
2323
#[must_use]
24-
pub fn new(name: String, doc: Option<String>) -> Self {
24+
pub const fn new(name: String, doc: Option<String>) -> Self {
2525
Self { name, doc }
2626
}
2727

@@ -134,7 +134,10 @@ impl TableDoc {
134134
/// # Errors
135135
/// - Will return [`DocError::ColumnNotFound`] if the expected table is not found
136136
pub fn column(&self, name: &str) -> Result<&ColumnDoc, DocError> {
137-
self.columns().binary_search_by(|c| c.name().cmp(name)).map_or_else(|_| Err(DocError::ColumnNotFound { name: name.to_owned() }), |id| Ok(&self.columns()[id]))
137+
self.columns().binary_search_by(|c| c.name().cmp(name)).map_or_else(
138+
|_| Err(DocError::ColumnNotFound { name: name.to_owned() }),
139+
|id| Ok(&self.columns()[id]),
140+
)
138141
}
139142

140143
/// Getter method for retrieving the table's [`Path`]

0 commit comments

Comments
 (0)