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() {
|
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 content = fs::read_to_string(&file).unwrap_or_else(|_| panic!("Could not read file '{file}'."));
|
||||||
let mut grid = Grid::from(content);
|
let mut grid = Grid::from(content);
|
||||||
let count = grid.fix();
|
let count = grid.fix();
|
||||||
|
@ -34,6 +34,9 @@ impl Grid {
|
||||||
let mut result = 0;
|
let mut result = 0;
|
||||||
let copy = self.clone();
|
let copy = self.clone();
|
||||||
for (y, line) in self.0.iter_mut().enumerate() {
|
for (y, line) in self.0.iter_mut().enumerate() {
|
||||||
|
if line == &vec!['-', '-', '-'] {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
for (x, character) in line.iter_mut().enumerate() {
|
for (x, character) in line.iter_mut().enumerate() {
|
||||||
if let Some(cross) = copy.cross_at(x as i32, y as i32) {
|
if let Some(cross) = copy.cross_at(x as i32, y as i32) {
|
||||||
let new_char = match cross {
|
let new_char = match cross {
|
||||||
|
@ -207,6 +210,8 @@ fn connects(c: char) -> Cross {
|
||||||
const F_: bool = false;
|
const F_: bool = false;
|
||||||
const MM: bool = true;
|
const MM: bool = true;
|
||||||
type Empt = ();
|
type Empt = ();
|
||||||
|
|
||||||
|
#[repr(Rust, packed)]
|
||||||
struct Cross(
|
struct Cross(
|
||||||
(Empt, bool, Empt), //
|
(Empt, bool, Empt), //
|
||||||
(bool, bool, bool), //
|
(bool, bool, bool), //
|
||||||
|
|
|
@ -17,3 +17,7 @@ this is a normalized data table diagram.
|
||||||
│ 1│ bob│ 19│
|
│ 1│ bob│ 19│
|
||||||
│ 2│ charlie│ 23│
|
│ 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
|
|
@ -9,13 +9,15 @@ this is a normalized data table diagram.
|
||||||
| 1|b@o.b| 1|
|
| 1|b@o.b| 1|
|
||||||
| 2|c@r.l| 2|
|
| 2|c@r.l| 2|
|
||||||
+--+-----+-------+
|
+--+-----+-------+
|
||||||
+---------------+
|
+---------------+
|
||||||
|USERS |
|
|USERS |
|
||||||
+--+--------+---+
|
+--+--------+---+
|
||||||
|id| name|age|
|
|id| name|age|
|
||||||
+--+--------+---+
|
+--+--------+---+
|
||||||
| 1| bob| 19|
|
| 1| bob| 19|
|
||||||
| 2| charlie| 23|
|
| 2| charlie| 23|
|
||||||
+--+--------+---+
|
+--+--------+---+
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
Fin.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue