Skip to content

Instantly share code, notes, and snippets.

View danielhenrymantilla's full-sized avatar
🦀

Daniel Henry-Mantilla danielhenrymantilla

🦀
View GitHub Profile
# http://www.graphviz.org/content/cluster
digraph G {
graph [fontname = "courier"];
node [fontname = "courier", shape=box];
edge [fontname = "courier"];
compound=true;
subgraph cluster_a {
digraph __crate__ {
subgraph cluster_Mir_0_10 {
graph [fontname="Courier, monospace"];
node [fontname="Courier, monospace"];
edge [fontname="Courier, monospace"];
// label=<fn main() -&gt; ()<br align="left"/>let mut _1: std::string::String;<br align="left"/>let mut _2: DropGlue&lt;&amp;mut std::string::String&gt;;<br align="left"/>let mut _3: &amp;mut std::string::String;<br align="left"/>let mut _4: *mut std::string::String;<br align="left"/>let _5: ();<br align="left"/>debug _2 =&gt; _2;<br align="left"/>debug _1 =&gt; _1;<br align="left"/>>;
bb0__0_10 [shape="none", label=<<table border="0" cellborder="1" cellspacing="0"><tr><td bgcolor="gray" align="center" colspan="1">0</td></tr><tr><td align="left" balign="left">StorageLive(_1)<br/></td></tr><tr><td align="left">_1 = String::new()</td></tr></table>>];
bb1__0_10 [shape="none", label=<<table border="0" cellborder="1" cellspacing="0"><tr><td bgcolor="gray" align="center" colspan="1">1</td></tr><tr><td align="left" balign="left">Sto
@danielhenrymantilla
danielhenrymantilla / _question.md
Last active June 2, 2023 11:49
Soundness of "existential lifetime" erasure

[These posts have been extracted from this Discord conversation, so as not to require readers to use their Discord account to read it 😔]

Question

HI!

Question and idea about narrowing lifetime of mutable references.

In rust code when developing finite state machines, behaviour trees and other algorithms we often need to pass around Context on which these algorithms will work.

MSRV Policy

The MSRV (Minimum Supported Rust [toolchain] Version) policy of my crates for a [semver-compatible bump] is the following:

stable - 9

More precisely:

  • Patch[^patch] bump ⇒ same MSRV

@danielhenrymantilla
danielhenrymantilla / resize-image-in-github-issue-github-flavored-markdown.md
Created February 21, 2022 14:14 — forked from stevecondylios/resize-image-in-github-issue-github-flavored-markdown.md
How to Resize an Image in a Github Issue (e.g. Github flavored Markdown)

How to Resize an Image in Github README.md (i.e. Github Flavored Markdown)

Percentage:

<img src="https://user-images.githubusercontent.com/16319829/81180309-2b51f000-8fee-11ea-8a78-ddfe8c3412a7.png" width=50% height=50%>

Pixels:

<img src="https://user-images.githubusercontent.com/16319829/81180309-2b51f000-8fee-11ea-8a78-ddfe8c3412a7.png" width="150" height="280">

@danielhenrymantilla
danielhenrymantilla / vec_of_array.md
Last active August 25, 2024 14:09
Vec off arrays (or slices)

Question

how can I convert an array to a vec without cloning the values

Technically-correct answer

Make a Vec of references:

array.iter_mut().collect::<Vec<_>>();
@danielhenrymantilla
danielhenrymantilla / lib.rs
Created December 15, 2021 00:50
Poorman's alloc-instrumentation
struct MyAllocator;
#[global_allocator]
static A: MyAllocator = MyAllocator;
const _: () = {
use ::std::{
alloc::{
GlobalAlloc,
Layout,

Summary

Panics which happen inside a Drop impl currently unwind as long as the drop was not itself called during unwinding (which would otherwise abort immediated due to a double-panic). This design meeting proposes to change this behavior to always abort if a panic attempts to escape a drop, even if this drop was invoked as part of normal function execution (as opposed to unwinding).

The dicussion on this issue dates back to 2014 (rust-lang/rust#14875) where the decision was made to support unwinding in drops but leave the door open to potentially reversing this decision.

Background reading

rust-lang/rust#86027

@danielhenrymantilla
danielhenrymantilla / parse_quote_dbg.rs
Created September 17, 2021 15:14 — forked from jmg-duarte/parse_quote_dbg.rs
Yandros parse_quote! debug
// Credits: Yandros#4299
macro_rules! parse_quote {(
$($code:tt)*
) => ({
eprintln!("[{}:{}:{}] parse_quote! {{ {} }}", file!(), line!(), column!(), quote!( $($code)* ));
::syn::parse_quote!( $($code)* )
})}
macro_rules! parse_quote {(
@danielhenrymantilla
danielhenrymantilla / SimpleHTTPServerWithUpload.py
Created July 15, 2021 18:07 — forked from UniIsland/SimpleHTTPServerWithUpload.py
Simple Python Http Server with Upload
#!/usr/bin/env python
"""Simple HTTP Server With Upload.
This module builds on BaseHTTPServer by implementing the standard GET
and HEAD requests in a fairly straightforward manner.
"""