FIND YOUR NEXT FEW LINES

Results for “Functions & data types”

Small, practical examples. Search by task or narrow things down below.

787 snippets foundClear filters
RustFunctions & data types

Accept different types with a generic function

Accept different types with a generic function in a complete Rust program using the standard library.

Rust✓ Tested
RustFunctions & data types

Store data in an enum variant

Store data in an enum variant in a complete Rust program using the standard library.

Rust✓ Tested
RustFunctions & data types

Capture a surrounding value in a closure

Capture a surrounding value in a closure in a complete Rust program using the standard library.

Rust✓ Tested
RustFunctions & data types

Construct a struct with default values

Construct a struct with default values in a complete Rust program using the standard library.

Rust✓ Tested
RustFunctions & data types

Define behavior with a trait

Define behavior with a trait in a complete Rust program using the standard library.

Rust✓ Tested
RustFunctions & data types

Derive comparison and debugging behavior

Derive comparison and debugging behavior in a complete Rust program using the standard library.

Rust✓ Tested
RustFunctions & data types

Implement a method on a struct

Implement a method on a struct in a complete Rust program using the standard library.

Rust✓ Tested
RustFunctions & data types

Use an associated constructor

Use an associated constructor in a complete Rust program using the standard library.

Rust✓ Tested
RustFunctions & data types

Wrap a value in a distinct type

Wrap a value in a distinct type in a complete Rust program using the standard library.

Rust✓ Tested
TypeScriptTypes & functions

Type a function’s inputs and output

Catch mismatched arguments during compilation.

function✓ Tested
TypeScriptObject behavior & collections

Copy nested structured data independently

TypeScript: structuredClone creates an independent copy of supported structured values.

TypeScript✓ Tested
GoFunctions & types

Accept a small behavior interface

Accept a small behavior interface using a complete Go program with explicit sample inputs.

Go✓ Tested