GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - robrix/Box: Swift µframework of the ubiquitous Box<T> & MutableBox<T> reference types, for recursive value types & misc. other purposes.

BranchesTags
Open more actions menu

Latest commit

 

History

86 Commits
86 Commits

Folders and files

NameName
Last commit message
Last commit date
Box.xcodeproj
Box.xcodeproj
 
 
Box
Box
 
 
BoxTests
BoxTests
 
 
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 

Repository files navigation

Box

This is a Swift microframework which implements Box<T> & MutableBox<T>, with implementations of ==/!= where T: Equatable.

Box is typically used to work around limitations of value types:

  • recursive structs/enums
  • type-parameterized enums where more than one case has a value

Use

Wrapping & unwrapping a Box:

// Wrap:
let box = Box(1)

// Unwrap:
let value = box.value

Changing the value of a MutableBox:

// Mutation:
let mutableBox = MutableBox(1)
mutableBox.value = 2

Building a recursive value type:

struct BinaryTree {
	let value: Int
	let left: Box<BinaryTree>?
	let right: Box<BinaryTree>?
}

Building a parameterized enum:

enum Result<T> {
	case Success(Box<T>)
	case Failure(NSError)
}

See the sources for more details.

Integration

  1. Add this repo as a submodule in e.g. External/Box:

     git submodule add https://github.com/robrix/Box.git External/Box
    
  2. Drag Box.xcodeproj into your .xcworkspace/.xcodeproj.

  3. Add Box.framework to your target’s Link Binary With Libraries build phase.

  4. You may also want to add a Copy Files phase which copies Box.framework (and any other framework dependencies you need) into your bundle’s Frameworks directory. If your target is a framework, you may instead want the client app to include Box.framework.

About

Swift µframework of the ubiquitous Box<T> & MutableBox<T> reference types, for recursive value types & misc. other purposes.

Resources

Readme
MIT license
Activity

Stars

217 stars

Watchers

4 watching

Forks

31 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.