Ignore md separators.
This commit is contained in:
parent
abc6241353
commit
4d3ed4d73a
4 changed files with 29 additions and 11 deletions
|
@ -1,7 +1,7 @@
|
|||
use std::{env::args, fs};
|
||||
use std::{env, fs};
|
||||
|
||||
fn main() {
|
||||
let file = args().nth(1).expect("Usage : boxon <file>");
|
||||
let file = env::args().nth(1).expect("Usage : boxon <file>");
|
||||
let content = fs::read_to_string(&file).unwrap_or_else(|_| panic!("Could not read file '{file}'."));
|
||||
let mut grid = Grid::from(content);
|
||||
let count = grid.fix();
|
||||
|
@ -34,6 +34,9 @@ impl Grid {
|
|||
let mut result = 0;
|
||||
let copy = self.clone();
|
||||
for (y, line) in self.0.iter_mut().enumerate() {
|
||||
if line == &vec!['-', '-', '-'] {
|
||||
continue;
|
||||
}
|
||||
for (x, character) in line.iter_mut().enumerate() {
|
||||
if let Some(cross) = copy.cross_at(x as i32, y as i32) {
|
||||
let new_char = match cross {
|
||||
|
@ -207,6 +210,8 @@ fn connects(c: char) -> Cross {
|
|||
const F_: bool = false;
|
||||
const MM: bool = true;
|
||||
type Empt = ();
|
||||
|
||||
#[repr(Rust, packed)]
|
||||
struct Cross(
|
||||
(Empt, bool, Empt), //
|
||||
(bool, bool, bool), //
|
||||
|
|
|
@ -17,3 +17,7 @@ this is a normalized data table diagram.
|
|||
│ 1│ bob│ 19│
|
||||
│ 2│ charlie│ 23│
|
||||
└──┴────────┴───┘
|
||||
|
||||
---
|
||||
|
||||
Fin.
|
7
test/run
Executable file
7
test/run
Executable file
|
@ -0,0 +1,7 @@
|
|||
#!/usr/bin/bash
|
||||
set -e
|
||||
cd "$(dirname "$(realpath "$0")")"
|
||||
cp source.txt out.txt
|
||||
|
||||
cd ..
|
||||
cargo run -- test/out.txt
|
|
@ -18,4 +18,6 @@ this is a normalized data table diagram.
|
|||
| 2| charlie| 23|
|
||||
+--+--------+---+
|
||||
|
||||
---
|
||||
|
||||
Fin.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue