Code Explainers

Code explainers tagged #slices

go
package batch
 
import "fmt"
 

Splitting a slice into batches in Go

generics slices error-handling
Intermediate 6 steps
rust
use std::cmp::Ordering;
 
pub struct PrefixIndex {
    entries: Vec<String>,

Prefix search with binary partitioning in Rust

binary-search sorting case-insensitive
Intermediate 7 steps
go
package collection
 
func Deduplicate[T comparable](items []T) []T {
	seen := make(map[T]struct{}, len(items))

Generic deduplication in Go

generics deduplication maps
Intermediate 5 steps
go
package main
 
import "fmt"
 

How Go slices grow and share memory

slices memory append
Intermediate 7 steps