Skip to content

Commit

Permalink
move base.rs into api.rs
Browse files Browse the repository at this point in the history
No real change here, just consolidating files because I keep clicking on
the wrong one. :-)
  • Loading branch information
yshavit authored Jul 25, 2024
1 parent a95868f commit 4a5154b
Show file tree
Hide file tree
Showing 11 changed files with 20 additions and 31 deletions.
13 changes: 12 additions & 1 deletion src/select/api.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use crate::parse_common::Position;
use crate::parsing_iter::ParsingIterator;
use crate::select::base::Selector;
use crate::select::sel_block_quote::BlockQuoteSelector;
use crate::select::sel_code_block::CodeBlockSelector;
use crate::select::sel_html::HtmlSelector;
Expand All @@ -18,6 +17,18 @@ pub type ParseResult<T> = Result<T, ParseErrorReason>;

pub const SELECTOR_SEPARATOR: char = '|';

pub trait Selector<'a, I: Copy + Into<MdElemRef<'a>>> {
fn matches(&self, item: I) -> bool;

fn try_select(&self, item: I) -> Option<MdElemRef<'a>> {
if self.matches(item) {
Some(item.into())
} else {
None
}
}
}

#[derive(Debug, Clone, PartialEq)]
pub struct ParseError {
pub position: Position,
Expand Down
13 changes: 0 additions & 13 deletions src/select/base.rs

This file was deleted.

1 change: 0 additions & 1 deletion src/select/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
mod api;
mod base;
mod sel_block_quote;
mod sel_code_block;
mod sel_html;
Expand Down
3 changes: 1 addition & 2 deletions src/select/sel_block_quote.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use crate::matcher::StringMatcher;
use crate::parsing_iter::ParsingIterator;
use crate::select::base::Selector;
use crate::select::{ParseResult, SELECTOR_SEPARATOR};
use crate::select::{ParseResult, Selector, SELECTOR_SEPARATOR};
use crate::tree::BlockQuote;

#[derive(Debug, PartialEq)]
Expand Down
3 changes: 1 addition & 2 deletions src/select/sel_code_block.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use crate::matcher::{CharEnd, StringMatcher};
use crate::parsing_iter::ParsingIterator;
use crate::select::base::Selector;
use crate::select::{ParseResult, SELECTOR_SEPARATOR};
use crate::select::{ParseResult, Selector, SELECTOR_SEPARATOR};
use crate::tree::{CodeBlock, CodeVariant};

#[derive(Debug, PartialEq)]
Expand Down
3 changes: 1 addition & 2 deletions src/select/sel_html.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use crate::matcher::StringMatcher;
use crate::parsing_iter::ParsingIterator;
use crate::select::base::Selector;
use crate::select::{ParseResult, SELECTOR_SEPARATOR};
use crate::select::{ParseResult, Selector, SELECTOR_SEPARATOR};
use crate::tree_ref::HtmlRef;

#[derive(Debug, PartialEq)]
Expand Down
3 changes: 1 addition & 2 deletions src/select/sel_image.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use crate::parsing_iter::ParsingIterator;
use crate::select::base::Selector;
use crate::select::sel_link::LinkMatchers;
use crate::select::ParseResult;
use crate::select::{ParseResult, Selector};
use crate::tree::Image;

#[derive(Debug, PartialEq)]
Expand Down
3 changes: 1 addition & 2 deletions src/select/sel_link.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use crate::matcher::StringMatcher;
use crate::parsing_iter::ParsingIterator;
use crate::select::base::Selector;
use crate::select::ParseResult;
use crate::select::{ParseResult, Selector};
use crate::tree::Link;

#[derive(Debug, PartialEq)]
Expand Down
3 changes: 1 addition & 2 deletions src/select/sel_list_item.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use crate::matcher::StringMatcher;
use crate::parsing_iter::ParsingIterator;
use crate::select::base::Selector;
use crate::select::{ParseErrorReason, ParseResult, SELECTOR_SEPARATOR};
use crate::select::{ParseErrorReason, ParseResult, Selector, SELECTOR_SEPARATOR};
use crate::tree_ref::ListItemRef;

#[derive(Debug, PartialEq)]
Expand Down
3 changes: 1 addition & 2 deletions src/select/sel_paragraph.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use crate::matcher::StringMatcher;
use crate::parsing_iter::ParsingIterator;
use crate::select::base::Selector;
use crate::select::{ParseResult, SELECTOR_SEPARATOR};
use crate::select::{ParseResult, Selector, SELECTOR_SEPARATOR};
use crate::tree::Paragraph;

#[derive(Debug, PartialEq)]
Expand Down
3 changes: 1 addition & 2 deletions src/select/sel_section.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use crate::matcher::StringMatcher;
use crate::parsing_iter::ParsingIterator;
use crate::select::base::Selector;
use crate::select::{ParseResult, SELECTOR_SEPARATOR};
use crate::select::{ParseResult, Selector, SELECTOR_SEPARATOR};
use crate::tree::Section;

#[derive(Debug, PartialEq)]
Expand Down

0 comments on commit 4a5154b

Please sign in to comment.