{"id":17043401,"url":"https://github.com/leavez/literal","last_synced_at":"2025-04-12T15:11:12.849Z","repository":{"id":62446607,"uuid":"88873118","full_name":"leavez/Literal","owner":"leavez","description":"convenient initializers for CGPoint and etc..","archived":false,"fork":false,"pushed_at":"2018-04-01T08:23:01.000Z","size":13,"stargazers_count":6,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-10T09:42:31.131Z","etag":null,"topics":["cgpoint","cgrect","convenience-extensions","ios"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/leavez.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-04-20T14:10:49.000Z","updated_at":"2024-04-13T18:52:04.000Z","dependencies_parsed_at":"2022-11-01T23:04:35.204Z","dependency_job_id":null,"html_url":"https://github.com/leavez/Literal","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leavez%2FLiteral","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leavez%2FLiteral/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leavez%2FLiteral/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leavez%2FLiteral/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/leavez","download_url":"https://codeload.github.com/leavez/Literal/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248586231,"owners_count":21128997,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cgpoint","cgrect","convenience-extensions","ios"],"created_at":"2024-10-14T09:29:28.021Z","updated_at":"2025-04-12T15:11:12.828Z","avatar_url":"https://github.com/leavez.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Literal\n\n[![Swift](https://img.shields.io/badge/swift-4.1-orange.svg?style=flat)](#)\n\nLiteral is a swift libiary to provide convenient initializers for CGPoint, CGRect, NSRange and etc.. \n\n```swift\nlet p: CGPoint = [0, 1]\nview.frame = [10, 20, 100, 100]\nmutableString.deleteCharacters(in: [0, 2])\n```\n\nIn Swift, a literal could be used anywhere an instance of an ExpressibleByXXXLiteral type is expected. For example, `let numbers: Set = [0, 1, 2]` is compilable as `Set` is comform to `ExpressibleByArrayLiteral`. \n\nThis feature come with the first version of swift. A library called [Literally](\"https://github.com/mattt/Literally\") is created at that time to demonstration this feature. However, the release of Swift 1.1 break this feature as it cannot be used on extension of object types. Fortunately, it could still be used on struct types and many of swift types have already implement this feature natively.\n\nThis lib implements ExpressibleByArrayLiteral protocol on some very commonly used types. With this a CGRect value could be initialized with an array of 4 numbers.\n\n\n## Support Types\n\nExpressibleByArrayLiteral\n\n- `CGPoint`\n- `CGSize`\n- `CGRect`\n- `CGVector`\n- `NSRange`\n- `UIEdgeInsets`\n\n**NOTE:** This break the complie safety. If you pass an array of 2 number to an CGRect variable, it won't produce an complie error. You may get an assert at runtime and a default value 0 is used in the release version. When the count of array is greater than needed, values in the front is used.\n\nExpressibleByStringLiteral\n\n- `CharacterSet`\n\nThese types support ExpressibleByArrayLiteral natively: `IndexPath`, `NSSet`, `Set`, `NSOrderedSet`, `NSCountedSet`, `CharacterSet` ...\n\n\n\n## Installation\n\nLiteral only have one source file. You could use it directly in your project as convenience.\n\nor use Cocoapods:\n\n```ruby\npod \"Literal\"\n```\nor Swift Package Manager:\n```swift\nimport PackageDescription\n\nlet package = Package(\n    name: \"MyAwesomeApp\",\n    dependencies: [\n        .Package(url: \"https://github.com/leavez/Literal.git\", \"1.0\"),\n    ]\n)\n```\n\n\n## License\n\nLiteral is available under the MIT license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleavez%2Fliteral","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleavez%2Fliteral","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleavez%2Fliteral/lists"}