Skip to content

Commit

Permalink
Readme and License (#1)
Browse files Browse the repository at this point in the history
* Update README.md

* Create LICENSE
  • Loading branch information
ay42 authored May 29, 2024
1 parent 1fe16a2 commit 393c0bb
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 1 deletion.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 SpaceNation Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
65 changes: 64 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,64 @@
# swift-equatable
# Swift Equatable Macro
![Swift Version](https://img.shields.io/badge/Swift-5.10-DE5D43)
[![License](https://img.shields.io/badge/License-MIT-blue)](LICENSE)

This package automatically generates `Equatable` conformance for both classes and actors. This means that you do not need to manually implement the `==` operator for your classes and actors, as this package will handle it for you.

By conforming to `Equatable`, instances of your classes and actors can be easily compared for equality, which is useful for many operations such as sorting, searching, and maintaining collections. This package ensures that the generated `==` operator correctly compares all relevant properties of your classes and actors, providing a robust and efficient implementation.

**Note**: Classes must be marked as final to use this package. This ensures that the synthesized `==` operator is accurate and efficient, as it does not need to account for potential subclassing.

## Usage

Add `@Equatable` annotation to class or actor

```swift
import Equatable

@Equatable
public final class Planet {
let name: String
let mass: Mass
}

/// Expands to
extension Planet: Equatable {
public static func == (lhs: Planet, rhs: Planet) -> Bool {
lhs.name == rhs.name &&
lhs.mass == rhs.mass
}
}
```

## Installation

To use the `Equatable` library in a SwiftPM project,
add it to the dependencies for your package and your target:

```swift
let package = Package(
// name, platforms, products, etc.
dependencies: [
// other dependencies
.package(url: "https://github.com/spacenation/swift-equatable", from: "1.0.0"),
],
targets: [
.target(
// name, etc.
dependencies: [
// other dependencies
.product(name: "Equatable", package: "wift-equatable")
]
)
// other targets
]
)
```

## Contributions

Feel free to contribute via fork/pull request to the main branch. If you want to request a feature or report a bug, please start a new issue.

## Become a Sponsor

If you find this project useful, please consider becoming our [GitHub Sponsor](https://github.com/sponsors/spacenation).

0 comments on commit 393c0bb

Please sign in to comment.