Debugging

package
v0.3.26 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 15, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PointerArrow is the arrow used to indicate the current position of the pointer.
	PointerArrow string = "^"
)

Variables

This section is empty.

Functions

func DoWithBackup

func DoWithBackup[T Backuper[E], E any](subject T, f uc.EvalOneFunc[T, bool]) error

DoWithBackup executes a function with a backup of the subject object.

Parameters:

  • subject: The object to create a backup of.
  • f: The function to execute.

Returns:

  • error: An error if the function fails.

Behaviors:

  • If the function fails or does not accept the subject object, the subject object is restored from the backup. Otherwise, the subject object is left as is.

func PrintPointer

func PrintPointer(distance int) string

PrintPointer generates a string representation of a pointer at a given distance.

Parameters:

  • distance: The distance of the pointer from the current position.

Returns:

  • string: A string representation of the pointer.

Behaviors:

  • Negative distance: The pointer is to the left of the current position.
  • Positive distance: The pointer is to the right of the current position.
  • 0: The pointer is at the current position.

Types

type Backuper

type Backuper[T any] interface {
	// Backup creates a backup of the object.
	//
	// Returns:
	//   - T: The backup of the object.
	Backup() T

	// Restore restores the object from a backup.
	//
	// Parameters:
	//   - backup: The backup of the object.
	//
	// Returns:
	//   - error: An error if the restoration fails.
	Restore(backup T) error
}

Backuper is an interface that represents a type that can be backed up and restored.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL