From 9d017eb6abc45f83d6a70b5e340549cae4d9a991 Mon Sep 17 00:00:00 2001 From: Rowan Torbitzky-Lane Date: Mon, 21 Apr 2025 16:35:08 -0500 Subject: [PATCH] remove pub from _ functions --- src/instructions/code.rs | 28 +++++++++++----------------- src/instructions/common.rs | 12 ++++++------ 2 files changed, 17 insertions(+), 23 deletions(-) diff --git a/src/instructions/code.rs b/src/instructions/code.rs index f7cf606..187dc19 100644 --- a/src/instructions/code.rs +++ b/src/instructions/code.rs @@ -316,7 +316,7 @@ pub fn code_map(state: &mut PushState) { /// If top bool is true, execute top element of code/exec stack and skip the second. /// If false, execute second element and skip the top. -pub fn _if(a: Gene, b: Gene, cond: bool) -> Option { +fn _if(a: Gene, b: Gene, cond: bool) -> Option { Some(if cond { a } else { b }) } @@ -344,7 +344,7 @@ pub fn exec_when(state: &mut PushState) { /// Pushes true if the second code item is found within the first item. /// If the first item isn't a block, coerced into one. -pub fn _member(a: Gene, b: Gene) -> Option { +fn _member(a: Gene, b: Gene) -> Option { let block = match b { Gene::Block(val) => val, val => vec![val], @@ -355,7 +355,7 @@ pub fn _member(a: Gene, b: Gene) -> Option { /// Pushes the nth item of the top element of the code stack. /// If top code item isn't a block, wrap one around it. -pub fn _nth(a: Gene, idx: i128) -> Option { +fn _nth(a: Gene, idx: i128) -> Option { let gene_vec = match a { Gene::Block(val) => val, val => vec![val], @@ -369,27 +369,21 @@ pub fn _nth(a: Gene, idx: i128) -> Option { } /// Pushes an empty block to the top of a stack. -pub fn _make_empty_block() -> Option { +fn _make_empty_block() -> Option { Some(Gene::Block(vec![])) } /// Checks to see if the top item on the code/exec stack is an empty block. /// True if is, False if not. -pub fn _is_empty_block(a: Gene) -> Option { +fn _is_empty_block(a: Gene) -> Option { Some(match a { - Gene::Block(val) => { - if val.is_empty() { - true - } else { - false - } - } + Gene::Block(val) => val.is_empty(), _ => false, }) } /// Returns the size of the top item on the code/exec stack. -pub fn _size(a: Gene) -> Option { +fn _size(a: Gene) -> Option { Some(match a.clone() { Gene::Block(val) => val.len() as i128, _ => 1, @@ -397,7 +391,7 @@ pub fn _size(a: Gene) -> Option { } /// Returns a nested element inside a block based on an int. -pub fn _extract(a: Gene, idx: i128) -> Option { +fn _extract(a: Gene, idx: i128) -> Option { match &a { block @ Gene::Block(_) => { let block_len = block.rec_len(); @@ -415,7 +409,7 @@ pub fn _extract(a: Gene, idx: i128) -> Option { /// Inserts a gene at a given position in into the top block based off an /// int from the top of the int stack. The top code item is coerced into a block /// if needed. -pub fn _insert(a: Gene, b: Gene, idx: i128) -> Option { +fn _insert(a: Gene, b: Gene, idx: i128) -> Option { let mut block = match a.clone() { iblock @ Gene::Block(_) => iblock, val => Gene::Block(vec![val]), @@ -431,7 +425,7 @@ pub fn _insert(a: Gene, b: Gene, idx: i128) -> Option { /// Pushes the first position of the 2nd code item within the top code item. /// If not found, pushes -1. If top code item isn't a block, returns 0 if top /// two code items equal, -1 otherwise. -pub fn _first_position(a: Gene, b: Gene) -> Option { +fn _first_position(a: Gene, b: Gene) -> Option { let bad_cond: bool = match &a { Gene::Block(val) => val.len() == 0, _ => true, @@ -456,7 +450,7 @@ pub fn _first_position(a: Gene, b: Gene) -> Option { } /// Reverses the top block. Does nothing if not a block. -pub fn _reverse(a: Gene) -> Option { +fn _reverse(a: Gene) -> Option { Some(match a { Gene::Block(mut val) => { val.reverse(); diff --git a/src/instructions/common.rs b/src/instructions/common.rs index 9bb8696..01ad523 100644 --- a/src/instructions/common.rs +++ b/src/instructions/common.rs @@ -70,31 +70,31 @@ macro_rules! make_code { } /// Duplicates an item -pub fn _dup(val: T) -> Option> { +fn _dup(val: T) -> Option> { Some(vec![val.clone(), val]) } -pub fn _dup_times(amt: i128, val: T) -> Option> { +fn _dup_times(amt: i128, val: T) -> Option> { Some(vec![val; amt as usize]) } /// Swaps two values -pub fn _swap(a: T, b: T) -> Option> { +fn _swap(a: T, b: T) -> Option> { Some(vec![a, b]) } /// Rotates three values -pub fn _rotate(a: T, b: T, c: T) -> Option> { +fn _rotate(a: T, b: T, c: T) -> Option> { Some(vec![c, a, b]) } /// Checks if two values are equal -pub fn _equal(a: T, b: T) -> Option { +fn _equal(a: T, b: T) -> Option { Some(b == a) } /// Checks if two values are not equal -pub fn _not_equal(a: T, b: T) -> Option { +fn _not_equal(a: T, b: T) -> Option { Some(b != a) }