Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Implementation of the `using` feature in Swift by code generation with SwiftSyntax

License

NotificationsYou must be signed in to change notification settings

alexito4/SwiftUsing

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SwiftUsing brings to Swift theusing feature from Jai,Jonathan Blow's programming language. It usesSwiftSyntax to code generate the required code.

To learn more aboutSwiftUsing development you can check out the blog postImplementing using in Swift with SwiftSyntax.

What isusing

using helps withStruct composition.

It allows you to recover the nice syntax from class inheritance when you usestructs instead.

structUser{varname:Stringvarage:Int}structFriend{    // usingletuser:UservarfriendshipDate:Date}friend.name // with class inheritancefriend.user.name // with struct composition :(friend.name // with struct composition and using !!

Usage

  1. Annotate a property with a comment:// using
struct Friend{...    // using          <- add this commentletuser:User...}

Note that both types must be in the same file. See Known limitations below.

  1. Run the command line tool

⚠️ This command will overwrite the original file so make sure you have a copy or you're using a versioning control system like Git in case something goes wrong.

swiftusing/path/to/file

Installation

Clone the repo and runmake install.

Known limitations

  • Basic declaration syntaxlet/var identifier: Type
  • Reliant on comments (is just an external tool after all)
  • Single file, using types must be in the same file.
  • No collision detection, the compiler will error instead.

## Acknowledgements

Contributions & support

SwiftUsing is developed completely in the open, and your contributions are more than welcome.

This project does not come with GitHub Issues-based support, and users are instead encouraged to become active participants in its continued development — by fixing any bugs that they encounter, or improving the documentation wherever it’s found to be lacking.

If you wish to make a change,open a Pull Request — even if it just contains a draft of the changes you’re planning, or a test that reproduces an issue — and we can discuss it further from there.

Author

Alejandro Martinez |http://alejandromp.com |@alexito4

About

Implementation of the `using` feature in Swift by code generation with SwiftSyntax

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp