swift-collection-parser

2.0.0

Swift package for a type `Parser<Subject: Collection>`.
Formkunft/swift-collection-parser

What's New

Swift Collection Parser 2.0.0

2025-02-28T22:43:39Z
  • Renamed package to swift-collection-parser and module to CollectionParser
  • Renamed read methods for single elements are now named pop
  • Renamed position from headIndex
  • Renamed remainder from rest
  • Added withView API
  • Fixed documentation

Full Changelog: v1.0.0...v2.0.0

Swift Collection Parser

Swift Collection Parser is a package for a type Parser<Subject: Collection>.

Description

The Parser type provides a simple parser that can be used to parse arbitrary collections.

var parser = Parser(subject: data)

guard let version = parser.pop() else {
	throw DecodingError.missingVersion
}
guard let string = String(bytes: parser.read(while: { $0 != 0 }), encoding: .utf8),
      parser.pop(0) else {
	throw DecodingError.invalidStringValue
}

Using Swift Collection Parser in your project

Add swift-collection-parser as a dependency to your package:

let package = Package(
	// ...
	dependencies: [
		.package(url: "https://github.com/Formkunft/swift-collection-parser", .upToNextMajor(from: "2.0.0")),
	],
	targets: [
		.target(
			// ...
			dependencies: [
				.product(name: "CollectionParser", package: "swift-collection-parser"),
			]),
	]
)

Then, import CollectionParser in your code:

import CollectionParser

// ...

Description

  • Swift Tools 6.0.0
View More Packages from this Author

Dependencies

  • None
Last updated: Wed May 14 2025 04:03:04 GMT-0900 (Hawaii-Aleutian Daylight Time)