diff options
| author | Michael Sullivan <sully@msully.net> | 2012-07-11 23:42:26 -0700 |
|---|---|---|
| committer | Michael Sullivan <sully@msully.net> | 2012-07-12 16:52:26 -0700 |
| commit | 2ea9c8df0f7c9ee72913883128b37d0a80d2f4f6 (patch) | |
| tree | b3e4acbf2912f804cb45f87e8819a5e4847ec213 /src/libstd | |
| parent | acb86921a62ba01726fd922f55d0176fa6c1df7c (diff) | |
| download | rust-2ea9c8df0f7c9ee72913883128b37d0a80d2f4f6.tar.gz rust-2ea9c8df0f7c9ee72913883128b37d0a80d2f4f6.zip | |
Accept prefix notation for writing the types of str/~ and friends.
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/json.rs | 8 | ||||
| -rw-r--r-- | src/libstd/map.rs | 4 | ||||
| -rw-r--r-- | src/libstd/rope.rs | 16 |
3 files changed, 14 insertions, 14 deletions
diff --git a/src/libstd/json.rs b/src/libstd/json.rs index 9f51ab157b7..da86b9d4df0 100644 --- a/src/libstd/json.rs +++ b/src/libstd/json.rs @@ -29,7 +29,7 @@ export null; /// Represents a json value enum json { num(float), - string(@str), + string(@str/~), boolean(bool), list(@~[json]), dict(map::hashmap<str, json>), @@ -39,7 +39,7 @@ enum json { type error = { line: uint, col: uint, - msg: @str, + msg: @str/~, }; /// Serializes a json value into a io::writer @@ -324,7 +324,7 @@ impl parser for parser { ok(res) } - fn parse_str() -> result<@str, error> { + fn parse_str() -> result<@str/~, error> { let mut escape = false; let mut res = ""; @@ -579,7 +579,7 @@ impl of to_json for str { fn to_json() -> json { string(@copy self) } } -impl of to_json for @str { +impl of to_json for @str/~ { fn to_json() -> json { string(self) } } diff --git a/src/libstd/map.rs b/src/libstd/map.rs index 8a2089c6f2b..cc88a91bcf2 100644 --- a/src/libstd/map.rs +++ b/src/libstd/map.rs @@ -310,8 +310,8 @@ fn str_hash<V: copy>() -> hashmap<str, V> { } /// Construct a hashmap for boxed string keys -fn box_str_hash<V: copy>() -> hashmap<@str, V> { - ret hashmap(|x: @str| str::hash(*x), |x,y| str::eq(*x,*y)); +fn box_str_hash<V: copy>() -> hashmap<@str/~, V> { + ret hashmap(|x: @str/~| str::hash(*x), |x,y| str::eq(*x,*y)); } /// Construct a hashmap for byte string keys diff --git a/src/libstd/rope.rs b/src/libstd/rope.rs index 4dc5116b509..91f63fe938c 100644 --- a/src/libstd/rope.rs +++ b/src/libstd/rope.rs @@ -53,7 +53,7 @@ fn empty() -> rope { * * this operation does not copy the string; * * the function runs in linear time. */ -fn of_str(str: @str) -> rope { +fn of_str(str: @str/~) -> rope { ret of_substr(str, 0u, str::len(*str)); } @@ -79,7 +79,7 @@ fn of_str(str: @str) -> rope { * * this function does _not_ check the validity of the substring; * * this function fails if `byte_offset` or `byte_len` do not match `str`. */ -fn of_substr(str: @str, byte_offset: uint, byte_len: uint) -> rope { +fn of_substr(str: @str/~, byte_offset: uint, byte_len: uint) -> rope { if byte_len == 0u { ret node::empty; } if byte_offset + byte_len > str::len(*str) { fail; } ret node::content(node::of_substr(str, byte_offset, byte_len)); @@ -107,7 +107,7 @@ fn append_char(rope: rope, char: char) -> rope { * * * this function executes in near-linear time */ -fn append_str(rope: rope, str: @str) -> rope { +fn append_str(rope: rope, str: @str/~) -> rope { ret append_rope(rope, of_str(str)) } @@ -127,7 +127,7 @@ fn prepend_char(rope: rope, char: char) -> rope { * # Performance note * * this function executes in near-linear time */ -fn prepend_str(rope: rope, str: @str) -> rope { +fn prepend_str(rope: rope, str: @str/~) -> rope { ret append_rope(of_str(str), rope) } @@ -567,7 +567,7 @@ mod node { byte_offset: uint, byte_len: uint, char_len: uint, - content: @str + content: @str/~ }; /** @@ -627,7 +627,7 @@ mod node { * Performance note: The complexity of this function is linear in * the length of `str`. */ - fn of_str(str: @str) -> @node { + fn of_str(str: @str/~) -> @node { ret of_substr(str, 0u, str::len(*str)); } @@ -648,7 +648,7 @@ mod node { * Behavior is undefined if `byte_start` or `byte_len` do not represent * valid positions in `str` */ - fn of_substr(str: @str, byte_start: uint, byte_len: uint) -> @node { + fn of_substr(str: @str/~, byte_start: uint, byte_len: uint) -> @node { ret of_substr_unsafer(str, byte_start, byte_len, str::count_chars(*str, byte_start, byte_len)); } @@ -674,7 +674,7 @@ mod node { * * Behavior is undefined if `char_len` does not accurately represent the * number of chars between byte_start and byte_start+byte_len */ - fn of_substr_unsafer(str: @str, byte_start: uint, byte_len: uint, + fn of_substr_unsafer(str: @str/~, byte_start: uint, byte_len: uint, char_len: uint) -> @node { assert(byte_start + byte_len <= str::len(*str)); let candidate = @leaf({ |
