78 Commits

Author SHA1 Message Date
CAD97
a39847804d Add test for indexing 2020-03-26 17:03:04 -04:00
CAD97
fe3fe80fa2 Re-add Index<TextRange> for String 2020-03-25 21:41:48 -04:00
CAD97
bf18e9f445 Bump dev version 2020-03-25 20:39:02 -04:00
bors[bot]
be44120d49 Merge rust-analyzer/text-size#31
31: Use standard generics for TextSize::of r=CAD97 a=CAD97

There is no specific reason to use APIT here, so prefer the form that allows more control for the user, in the form of the turbofish.

Co-authored-by: CAD97 <cad97@cad97.com>
2020-03-26 00:18:03 +00:00
CAD97
9cca8e26f0 Use standard generics for TextSize::of
There is no specific reason to use APIT here, so prefer the form that allows more control for the user, in the form of the turbofish.
2020-03-25 20:17:35 -04:00
CAD97
0f09f1d10d Just unwrap in LenTextSize for &str 2020-03-25 20:15:28 -04:00
CAD97
cda9765cae Fix broken intra doc link 2020-03-25 20:05:18 -04:00
Aleksey Kladov
8c3d31f4f2 Merge pull request rust-analyzer/text-size#27 from CAD97/ci-docs
Ensure docs build
2020-03-24 17:21:11 +01:00
bors[bot]
128f45fb10 Merge rust-analyzer/text-size#29
29: TextSized is not meant to be used directly... r=matklad a=CAD97

so rename it to a name more distinct from TextSize.

Co-authored-by: CAD97 <cad97@cad97.com>
2020-03-24 08:58:25 +00:00
CAD97
ade5c7b7d6 TextSized is not meant to be used directly...
so rename it to a name more distinct from TextSize.
2020-03-23 21:36:09 -04:00
CAD97
e497041625 Make sure docs build on CI 2020-03-23 21:31:39 -04:00
CAD97
9aa3cabcef Add doc examples to things 2020-03-23 21:30:39 -04:00
CAD97
211ae81ad0 Tests to ensure common and auto trait presence 2020-03-23 17:03:43 -04:00
CAD97
5468ef0a9f Move construction tests into a test 2020-03-23 16:45:18 -04:00
CAD97
3b9d00e65d Add assertion for TextSized impls 2020-03-23 16:38:34 -04:00
CAD97
ba1fd73c12 target the TextSized blanket impl more tightly" 2020-03-23 16:38:34 -04:00
CAD97
5f3a2c2aec add recursive impl for TextSized 2020-03-23 16:38:34 -04:00
Aleksey Kladov
8d9a1a4192 Make TextRange constructors more boring
Remove `fn TextRange(` as that's slightly unusual and surprising,
which will add up to a lot of confusion over the long run.

Instead add:

* `new` as the biased, canonical way to create range from bounds
* `from_len` as an alternative ctor from starting position and len
* `empty` for empty ranges at a given offset
* `up_to` for ranges at zero offset with given length
* `default` for an empty range at zero
2020-03-22 09:23:43 +01:00
Christopher Durham
16334551bd Add licensing text to README 2020-03-20 20:21:44 -04:00
bors[bot]
4bcf23e99d Merge rust-analyzer/text-size#22
22: Make intersect and cover into methods r=matklad a=matklad

r? @CAD97 

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-03-20 23:43:44 +00:00
Aleksey Kladov
6c8c54ef15 Update src/range.rs
Co-Authored-By: Christopher Durham <cad97@cad97.com>
2020-03-21 00:43:20 +01:00
Aleksey Kladov
5ae5d6e1fc Swithc to GitHub actions 2020-03-20 17:17:40 +01:00
Aleksey Kladov
d8b8a9854b Rename repo 2020-03-20 17:12:32 +01:00
Aleksey Kladov
0edd20912e Make intersect and cover into methods 2020-03-20 09:46:15 +01:00
CAD97
8e7c7d3589 correct translation table 2020-03-19 13:55:11 -04:00
CAD97
2053ee9633 Add ops for TextRange 2020-03-19 13:52:56 -04:00
CAD97
b87db0e34f Remove unneeded import 2020-03-19 12:38:54 -04:00
CAD97
e8011ac880 Remove TextRange::offset (for now?) 2020-03-19 11:35:52 -04:00
CAD97
a3d5d63208 Remove TextSize::ASCII 2020-03-19 11:30:40 -04:00
CAD97
14a1f78557 Remove incorrect doc comment 2020-03-19 11:29:54 -04:00
CAD97
156f423434 rename TextRange::before to up_to 2020-03-19 11:29:36 -04:00
CAD97
347db5a780 remove TextRange::after 2020-03-18 17:23:37 -04:00
CAD97
e89c6e8b1b replace one with ascii 2020-03-18 17:22:00 -04:00
CAD97
0c77efb0c5 Add #[inline] to most things 2020-03-18 17:21:02 -04:00
CAD97
6d6e97e901 minor improvements everywhere 2020-03-18 17:21:02 -04:00
Christopher Durham
d988daaedc Add missing _ 2020-03-15 11:15:37 -04:00
CAD97
a5f9151896 Don't silently wrap for too-large str 2020-03-14 22:17:24 -04:00
CAD97
e9f7d87ee6 minor serde style fix 2020-03-14 21:50:15 -04:00
Aleksey Kladov
bb763ae76a Check invariant during deserialization 2020-03-13 21:28:14 +01:00
bors[bot]
41299f705e Merge rust-analyzer/text-size#13
13: Alternative set of contains function r=CAD97 a=matklad

Motivation:

TextRange is a set, it contains elements (TextSize). For this reason,
for range-range op we use a more verbose `contains_range` name.

In stdlib, there's `HashSet::is_subset`. We used a similar design with
`is_subrage` before, but it was very confusing in practice -- you'll
have to lookup docs for which of lhs and rhs is sub and super set.

Additionally, exclusive semantics is a clear default with better
properties (if you have a partitioning of a range into subranges, only
one of the parts contains any given offset), so it make sense to call
it `contains` and reserve `contains_inclusive` for another op.

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-03-13 15:40:03 +00:00
CAD97
1341116d14 Provide generic ref-removing ops for TextSize 2020-03-13 10:42:46 -04:00
bors[bot]
9719ae30d7 Merge rust-analyzer/text-size#16
16: Add a `From<TextRange>` impl r=CAD97 a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-03-13 14:31:04 +00:00
bors[bot]
e5d76bb872 Merge rust-analyzer/text-size#11
11: Switch to mathematical range notation r=matklad a=matklad

Just an option: `[10..20)` feel like a weird mix of rust and math. `[10, 20)` is just picking the math notation. 

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-03-13 09:28:39 +00:00
Aleksey Kladov
930462df0a Switch to Rust range notation 2020-03-13 10:27:47 +01:00
Aleksey Kladov
43ef8e44eb Add a From<TextRange> impl 2020-03-13 10:26:24 +01:00
Aleksey Kladov
894afd0644 Alternative set of contains function
Motivation:

TextRange is a set, it contains elements (TextSize). For this reason,
for range-range op we use a more verbose `contains_range` name.

In stdlib, there's `HashSet::is_subset`. We used a similar design with
`is_subrage` before, but it was very confusing in practice -- you'll
have to lookup docs for which of lhs and rhs is sub and super set.

Additionally, exclusive semantics is a clear default with better
properties (if you have a partitioning of a range into subranges, only
one of the parts contains any given offset), so it make sense to call
it `contains` and reserve `contains_inclusive` for another op.
2020-03-12 16:16:53 +01:00
Aleksey Kladov
c44a24e42d Fix ix 2020-03-12 15:57:07 +01:00
bors[bot]
e27818ef72 Merge rust-analyzer/text-size#6
6: Alternative set of conversions r=matklad a=matklad

@CAD97 what do yo think about this set of conversions? The idea here is that

* we provide From's for `u32`, because `TextSize` is, transparently, an `u32`. 
* we don't provide other fixed sized conversions -- I don't think I've ever needed them, and `TextSize` is not exactly the number, so forcing the occasional user to two a two step conversion seems OK: first covnersions changes to a raw repr, the second conversion is a numeric cast. This is in contrast two a one-step conversion, which mixes both numeric cast and raw-typed.
* We provide `TryFrom<usize>` (because that can fail) and `Into<usize>` (because that can't fail. If you are on 16bit machine, you probably want to use u16 for TextSize anyway). Unlike stdlib, we can be more aggressive here. 

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-03-12 14:42:50 +00:00
Aleksey Kladov
79435fce0e Merge pull request rust-analyzer/text-size#9 from CAD97/textsize-fmt
Remove Display for TextSize
2020-03-12 12:37:16 +01:00
Aleksey Kladov
485351360a Be 16-bit clean 2020-03-12 12:31:37 +01:00