Examples

Page 10 of 50

Browse code examples

rustSnippet

Next Permutation In Place

Find the rightmost ascent, swap with the last larger element, reverse the suffix, and reverse everything when the sequence is already maximal.

rustSnippet

Command Reads Piped Stdin

Spawn a child with Stdio::piped stdin, write one buffer into its handle, then collect stdout after the write end drops and the child sees EOF.

rustSnippet

Repeated Characters Via Entry

Count characters through a HashMap entry increment, keep counts above one, and sort the pairs so reports of repeated characters are complete and stable.

rustSnippet

Reverse Words In A Sentence

Split a borrowed sentence into whitespace words, reverse the iterator, collect, and rejoin while the source string stays usable because nothing moved.

rustSnippet

Vec Swap Reorders By Index

Reorder elements in place with Vec::swap by index, then run selection-sort's opening move by finding the minimum with min_by and swapping it to front.

sqlSnippet

BTree Index Row Size Limit

B-tree entries have a hard row-size ceiling, so an index on an incompressible wide text column builds empty but fails on the first oversized insert.