This file contains 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
/** | |
* Objective: Create constraint validation error reporting types, and/or, structs to | |
* be used by constraint validation types. | |
*/ | |
use std::collections::{HashSet, HashMap}; | |
use std::fmt; | |
use std::fmt::Debug; | |
use std::fmt::Display; | |
use std::error::Error; |
This file contains 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
/// Demonstrates an approach for accepting different types of functions, with different lifetimes | |
/// as struct values. | |
type MyFn = dyn Fn(); | |
struct ContainsFns<'a> { | |
other_fn: &'a MyFn, | |
fns: Option<Vec<&'a MyFn>> | |
} |
This file contains 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::fmt::{Display}; | |
use std::borrow::Cow; | |
/// Represent some scalar values for test. | |
/// | |
trait InputValue: Copy + Default + Display + PartialEq + PartialOrd {} | |
impl InputValue for isize {} | |
impl InputValue for usize {} | |
impl InputValue for &str {} |
This file contains 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
language | english_name | native_name | |
---|---|---|---|
af | Afrikaans | Afrikaans | |
ar | Arabic | العربية | |
ary | Moroccan Arabic | العربية المغربية | |
as | Assamese | অসমীয়া | |
az | Azerbaijani | Azərbaycan dili | |
azb | South Azerbaijani | گؤنئی آذربایجان | |
bel | Belarusian | Беларуская мова | |
bg_BG | Bulgarian | Български | |
bn_BD | Bengali (Bangladesh) | বাংলা |
This file contains 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
/** | |
* Custom modal "backdrop" animation replacement, until `::backdrop` animations are supported. | |
*/ | |
document.body.innerHTML = ` | |
<style> | |
body { | |
display: grid; | |
place-content: center; | |
} |
This file contains 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
/** | |
* Single threaded "filters" patterns. | |
*/ | |
use std::borrow::{Cow, Cow::*}; | |
pub type Filter<'a, T> = &'a dyn Fn(Cow<'a, T>) -> Cow<'a, T>; | |
fn filter<'a>(filters: &'a [Filter<'a, str>], value: Cow<'a, str>) -> Cow<'a, str> { | |
filters.iter().rfold(value, |agg, f| f(agg)) | |
} |
This file contains 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 core::fmt::Formatter; | |
/** | |
* The goal of this example is to show a way to have algebraic types and generics | |
* represent a collection of structs that can each have their own types and | |
* additionally be structurally different from each other. | |
* | |
* Question: Are there less "typeful"/verbose ways of acheiving the same this? | |
*/ | |
use core::fmt::{Display, Debug}; | |
use std::borrow::Cow; |
This file contains 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
// Note: in real world example things would work slightly differntly: | |
// ---- | |
const matSymStyleSheet = new CSSStyleSheet(); | |
// Load css for custom 'x-icon' element - In realword scenario css can be loaded using import assertions, and/or, | |
// directly via app facilities (sass, webpack, etc.). | |
fetch('https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200') | |
.then(res => res.text()) | |
.then(css => matSymStyleSheet.replace(` | |
${css.replace('.material-symbols-outlined', ':host .material-symbols-outlined')} |
This file contains 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
document.body.innerHTML = ` | |
<style> | |
html, body { | |
margin: 0; | |
padding: 0; | |
font: normal 1rem Arial, Sans-serif; | |
} | |
dialog { | |
margin: 0; | |
padding: 0; |
This file contains 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
const {log} = console, | |
groupContent = '.'.repeat(5).split('').reduce((agg, _, i) => { | |
return agg + `<item>` + | |
`<title>Item ${i}</title>` + | |
`</item>`; | |
}, ''), | |
docContent = `<group>${groupContent}</group>`, | |
NewerOlder