- Start Date: 2017-06-15
- RFC: https://github.com/rust-lang/rfcs/blob/master/text/2033-experimental-coroutines.md
- PR: rust-lang/rfcs#2033
- Issue: rust-lang/rust#43122
関連: RFC 2394
// ==UserScript== | |
// @name Bing Chat IME fix | |
// @namespace https://gist.github.com/koseki/d377f8f2e6df6655a1e160a4e03421d1 | |
// @version 0.4 | |
// @description macOS の Edge で Bing chat を使うと日本語入力確定時に勝手に送信されてしまう問題の対応です | |
// @author koseki | |
// @icon https://www.google.com/s2/favicons?sz=64&domain=tampermonkey.net | |
// @match https://www.bing.com/* | |
// @grant none | |
// ==/UserScript== |
#!/usr/bin/env sh | |
# usage: sh ./generate-target-dependencies.sh | dot -Tsvg -o target-graph.svg | |
packages=`swift package describe --type json` | |
targets=`echo $packages | jq '.targets'` | |
target_names=`echo $targets | jq -r '.[] | .name'` | |
body="" | |
template=`cat <<EOF | |
digraph DependenciesGraph { |
//------------------------------------------------------------------------ | |
// The SwiftUI Lab: Advanced SwiftUI Animations | |
// https://swiftui-lab.com/swiftui-animations-part1 (Animating Paths) | |
// https://swiftui-lab.com/swiftui-animations-part2 (GeometryEffect) | |
// https://swiftui-lab.com/swiftui-animations-part3 (AnimatableModifier) | |
//------------------------------------------------------------------------ | |
import SwiftUI | |
struct ContentView: View { | |
関連: RFC 2394
URLSession.shared.rx | |
.response(imageURL) | |
// subscribe on main thread | |
.subscribeOn(MainScheduler.sharedInstance) | |
.subscribe(onNext: { [weak self] data in | |
// Update Image | |
self?.imageView.image = UIImage(data: data) | |
}, onError: { | |
// Log error | |
}, onCompleted: { |
Modern Cocoa development involves a lot of asynchronous programming using closures and completion handlers, but these APIs are hard to use. This gets particularly problematic when many asynchronous operations are used, error handling is required, or control flow between asynchronous calls gets complicated. This proposal describes a language extension to make this a lot more natural and less error prone.
This paper introduces a first class Coroutine model to Swift. Functions can opt into to being async, allowing the programmer to compose complex logic involving asynchronous operations, leaving the compiler in charge of producing the necessary closures and state machines to implement that logic.
//: Playground - noun: a place where people can play | |
import Cocoa | |
enum Enum { | |
case SimpleCase | |
case AssociatedValue(String) | |
case AnotherAssociated(Int) | |
} | |
extension Enum { |
class TranslucentWin:NSWindow, NSApplicationDelegate, NSWindowDelegate{ | |
/** | |
* | |
*/ | |
override init(contentRect: NSRect, styleMask aStyle: Int, backing bufferingType: NSBackingStoreType, `defer` flag: Bool) { | |
super.init(contentRect: Win.sizeRect, styleMask: NSTitledWindowMask|NSResizableWindowMask|NSMiniaturizableWindowMask|NSClosableWindowMask|NSFullSizeContentViewWindowMask, backing: NSBackingStoreType.Buffered, `defer`: false) | |
self.contentView!.wantsLayer = true;/*this can and is set in the view*/ | |
self.backgroundColor = NSColor.greenColor().alpha(0.2) | |
self.opaque = false | |
self.makeKeyAndOrderFront(nil)//moves the window to the front |
\lstdefinelanguage{swift} | |
{ | |
morekeywords={ | |
func,if,then,else,for,in,while,do,switch,case,default,where,break,continue,fallthrough,return, | |
typealias,struct,class,enum,protocol,var,func,let,get,set,willSet,didSet,inout,init,deinit,extension, | |
subscript,prefix,operator,infix,postfix,precedence,associativity,left,right,none,convenience,dynamic, | |
final,lazy,mutating,nonmutating,optional,override,required,static,unowned,safe,weak,internal, | |
private,public,is,as,self,unsafe,dynamicType,true,false,nil,Type,Protocol, | |
}, | |
morecomment=[l]{//}, % l is for line comment |