This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// internal iterator struct that parses labels. Use this internally during | |
// parsing to validate that a payload is valid (just iterate it to completion, | |
// checking that no Errors occur) | |
#[derive(Debug, Clone)] | |
struct ParsingLabels<'a> { | |
// This must be the *full* DNS packet, including the header bytes | |
payload: &'a [u8], | |
// The position of the next label to read | |
next: usize, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::{borrow::Cow, collections::HashMap, num::ParseFloatError}; | |
use nom::{ | |
branch::alt, | |
bytes::complete::{is_not, tag}, | |
character::complete::{char, digit1, multispace0, satisfy}, | |
combinator::{map, map_opt, map_res, opt, recognize, value}, | |
error::{FromExternalError, ParseError}, | |
multi::fold_many_m_n, | |
sequence::{preceded, separated_pair, tuple}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#![feature(min_const_generics)] | |
use core::mem::ManuallyDrop; | |
use core::iter::FusedIterator; | |
use core::mem; | |
struct Array<T, const N: usize> { | |
data: [T; N], | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pub trait Swap { | |
fn swap(&mut self, other: &mut Self); | |
fn replace(&mut self, other: Self) -> Self; | |
} | |
impl<T: Sized> Swap for T { | |
fn swap(&mut self, other: &mut Self) { | |
std::mem::swap(self, other) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::{ | |
hash::Hasher, | |
io, | |
pin::Pin, | |
task::{Context, Poll}, | |
}; | |
use futures::AsyncRead; | |
use pin_project::pin_project; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::io::{self, BufReader, BufWriter, Read}; | |
use std::net; | |
#[derive(Debug, Copy, Clone)] | |
struct SlamParams<'a> { | |
prefix_length: usize, | |
payload: &'a [u8], | |
} | |
fn deliver_payload(mut dest: impl io::Write, params: SlamParams) -> io::Result<()> { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I am the Miaou user with id 5589 and name "Lucretiel" on https://miaou.dystroy.org |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::convert::TryFrom; | |
use nom::branch::alt; | |
use nom::bytes::streaming::{is_not, take}; | |
use nom::character::streaming::char; | |
use nom::combinator::{map, map_res, value, verify}; | |
use nom::error::ParseError; | |
use nom::multi::fold_many0; | |
use nom::sequence::{delimited, preceded}; | |
use nom::IResult; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[derive(Debug, Copy, Clone, PartialEq, Eq)] | |
enum Sign { | |
Positive, | |
Negative, | |
} | |
/// Partially parse a signed integer. Return the sign (if present) and | |
/// the unsigned integer part | |
fn parse_signed<E>(input: &str) -> IResult<&str, (Option<Sign>, u64), E> { | |
pair( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn solve(input: &str) -> impl Display { | |
let init: Vec<Cell<usize>> = input | |
.trim() | |
.split(',') | |
.map(|value| value.parse::<usize>().unwrap().into()) | |
.collect(); | |
let mut memory = Vec::new(); |