Examples

Page 3 of 50

Browse code examples

javaSnippet

CompareTo Orders By Code Unit

String.compareTo compares UTF-16 code units one position at a time, so uppercase letters sort before lowercase and prefixes yield a length difference.

javascriptSnippet

Late abort Listeners Never Fire

Adding an abort listener after the signal already aborted does not throw and does not fire, so cleanup paths must check signal.aborted before subscribing.

rustSnippet

Vec leak Into Static Slice

Convert an owned Vec into a static-lifetime slice with Vec::leak, trading the deallocation path for data that lives for the whole program.