Added documentation.

This commit is contained in:
Kare Morstol
2014-08-28 20:28:13 +02:00
parent a31f018c6b
commit e0122983df
2 changed files with 10 additions and 9 deletions
+5 -8
View File
@@ -22,13 +22,13 @@ public protocol ReadableStreamType : Streamable {
*/
func readSome() -> String?
/// Reads everything at once.
/** Reads everything at once. */
func read() -> String
/// Lazily splits the stream into lines
/** Lazily splits the stream into lines. */
func lines() -> SequenceOf<String>
/// Allows stream to be used by "println"
/** Allows stream to be used by "println". */
func writeTo<Target : OutputStreamType>(inout target: Target)
}
@@ -37,12 +37,12 @@ public protocol WriteableStreamType : OutputStreamType {
func write(string: String)
/// Must be called on local streams when done writing.
/** Must be called on local streams when done writing. */
func closeStream()
}
/** Creates a stream from a String. */
public func stream(text: String) -> ReadableStreamType {
public func stream (text: String) -> ReadableStreamType {
let pipe = NSPipe()
let input = pipe.fileHandleForWriting
input.write(text)
@@ -59,9 +59,6 @@ public func stream ( closureclosure:() -> () -> String? ) -> ReadableStreamType
if let text = closure() {
filehandle.write(text)
} else {
// why won't this work? (beta 6)
// filehandle.writeabilityHandler = nil
input.writeabilityHandler = nil
}
}
+5 -1
View File
@@ -22,7 +22,11 @@ extension String {
return self.stringByTrimmingCharactersInSet(NSCharacterSet.whitespaceAndNewlineCharacterSet())
}
/// Split the string at the first occurrence of separator, and return a 3-tuple containing the part before the separator, the separator itself, and the part after the separator. If the separator is not found, return a 3-tuple containing the string itself, followed by two empty strings.
/**
Splits the string at the first occurrence of separator, and returns a 3-tuple containing the part
before the separator, the separator itself, and the part after the separator. If the separator is
not found, returns a 3-tuple containing the string itself, followed by two empty strings.
*/
public func partition(separator: String) -> (String, String, String) {
if let separatorRange = self.rangeOfString(separator) {
if !separatorRange.isEmpty {