Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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, mem}; | |
| use chumsky::{Parser as _, prelude::*}; | |
| use freya::{icons::lucide::hash, prelude::*}; | |
| use pulldown_cmark::{Event, HeadingLevel, Options, Parser, Tag, TagEnd}; | |
| define_theme! { | |
| %[component] | |
| pub MarkdownViewer { | |
| %[fields] |
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 app() -> impl IntoElement { | |
| let value = use_state(|| 0); | |
| rect() | |
| .background(0xff292a2f) | |
| .color(0xffe3e1e9) | |
| .width(Size::Fill) | |
| .height(Size::Fill) | |
| .spacing(8.) | |
| .font_size(14.) |
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
| macro_rules! generate_field_diff { | |
| (optional, $self:ident, $before:ident, $partial:ident, $field:ident) => { | |
| if $partial.$field.is_some() { | |
| $before.$field = $self.$field.clone(); | |
| }; | |
| }; | |
| ($self:ident, $before:ident, $partial:ident, $field:ident) => { | |
| if $partial.$field.is_some() { | |
| $before.$field = Some($self.$field.clone()); |
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
| type StringFlags = "c" | "b" | "B"; | |
| type NumberFlags = "n" | |
| type Resolve<T extends string> = ( | |
| T extends StringFlags ? [string] : | |
| T extends NumberFlags ? [number] : | |
| [] // ignore stuff like ">" | |
| ); | |
| type Repeat< |
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
| from __future__ import annotations | |
| from typing import TYPE_CHECKING, Any, ClassVar, Generic, Literal, Self, TypeVar, Annotated, TypeVarTuple, get_args, overload, get_origin, reveal_type, cast | |
| import asyncpg | |
| T = TypeVar("T") | |
| T_T = TypeVar("T_T", bound="Table", covariant=True) | |
| T_OT = TypeVar("T_OT", bound="Table", covariant=True) | |
| T_Ts = TypeVarTuple("T_Ts") |
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
| type IsValid<Name> = Name extends `${infer _} ${infer _}` | |
| ? never | |
| : Name; | |
| type IsParameter<Part> = Part extends `\$${infer Parameter}` | |
| ? IsValid<Parameter> | |
| : never; | |
| type QueryParser<Query> = Query extends `${infer A}${' ' | '='}${infer B}` | |
| ? IsParameter<A> | QueryParser<B> |
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
| from __future__ import annotations | |
| from dataclasses import dataclass | |
| from types import NoneType, UnionType | |
| from typing import Annotated, Any, Callable, Generic, Iterable, TypeGuard, TypeVar, Union, cast, get_origin as _get_origin, get_args, Self | |
| T = TypeVar("T") | |
| # isistance doesnt allow the second paramter to be generic so we must get the origin, however typing.get_origin doesnt return the class if its not generic | |
| # so we default back to the type ourself |
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::{any::Any, collections::HashMap}; | |
| trait VTable<G = ()> { | |
| const NAME: &'static str; | |
| fn table(&self) -> HashMap<&str, &'static dyn Any>; | |
| fn get<T: 'static>(&self, name: &str) -> &T { | |
| let table = self.table(); | |
| let any = table[name]; |
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 bumpalo::Bump; | |
| use std::fmt; | |
| mod lifetimes { | |
| use std::mem; | |
| pub unsafe fn extend_lifetime<'a, 'b, T>(value: &'a T) -> &'b T { | |
| mem::transmute(value) | |
| } |
NewerOlder