pub struct Aoc { /* private fields */ }Implementations§
Source§impl Aoc
impl Aoc
Sourcepub fn new(day: u8, year: i32) -> Self
pub fn new(day: u8, year: i32) -> Self
Creates a new Aoc.
§Arguments
day-> day of aoc you want to solveyear-> year of aoc you want to solve
§Examples:
use aoc_bud::Aoc;
// Create a new handler for the first aoc day of 2023
let aoc = Aoc::new(1, 2023);§Panics
Panics if:
- .env file is not present
- AOC_SESSION is not present in .env
- Current working directory is not writteable
Sourcepub fn input(&self) -> String
pub fn input(&self) -> String
Returns the input of the puzzle of the corresponding day.
§Examples:
use aoc_bud::Aoc;
let aoc: Aoc = Aoc::new(1, 2023);
let input: String = aoc.input();§Panics
Panics if:
- It can’t perform a request
- Current working directory is not writteable
- The selected date and year don’t have a puzzle yet or don’t exist
Sourcepub fn test_input(&self) -> String
pub fn test_input(&self) -> String
Returns the test input of the puzzle of the corresponding day.
§Examples:
use aoc_bud::Aoc;
let aoc: Aoc = Aoc::new(1, 2023);
let test_input: String = aoc.test_input();§Panics
Panics if:
- It can’t perform a request
- It can’t find the test input in the webpage
- Current working directory is not writteable
- The selected date and year don’t have a puzzle yet or don’t exist
Sourcepub fn solve1<T: ToString>(&self, solution: T) -> Result<(), String>
pub fn solve1<T: ToString>(&self, solution: T) -> Result<(), String>
Send the solution for the first puzzle, will return Ok if correct.
§Argument
solution-> your solution
§Example:
use aoc_bud::Aoc;
let aoc: Aoc = Aoc::new(1, 2023);
let input: String = aoc.input();
let solution = get_solution(input);
// Unwrap so we can get the result
aoc.solve1(solution).unwrap();§Errors
This function will return an error if:
- It can’t perform a request
- The solution is incorrect
- You sent the solution too quickly
- You are trying to solve a puzzle already solved
- The selected date and year don’t have a puzzle yet or don’t exist
Sourcepub fn solve2<T: ToString>(&self, solution: T) -> Result<(), String>
pub fn solve2<T: ToString>(&self, solution: T) -> Result<(), String>
Send the solution for the second puzzle, will return Ok if correct.
§Argument
solution-> your solution
§Example:
use aoc_bud::Aoc;
let aoc: Aoc = Aoc::new(1, 2023);
let input: String = aoc.input();
let solution = get_solution(input);
// Unwrap so we can get the result
aoc.solve2(solution).unwrap();§Errors
This function will return an error if:
- It can’t perform a request
- The solution is incorrect
- You sent the solution too quickly
- You are trying to solve a puzzle already solved
- You are trying to solve the 2nd puzzle without having solved the 1st
- The selected date and year don’t have a puzzle yet or don’t exist
Auto Trait Implementations§
impl Freeze for Aoc
impl RefUnwindSafe for Aoc
impl Send for Aoc
impl Sync for Aoc
impl Unpin for Aoc
impl UnwindSafe for Aoc
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more