Skip to content
smoeliusPublic

About

Rust utilities for rewriting files

Topics

Resources

Stars

2 stars

Watchers

1 watching

Forks

Latest commit

 

History

99 Commits

Folders and files

Repository files navigation

rewriter

Rust utilities for rewriting files

Main exports

Features

  • proc-macro2-span: By default, rewriter uses its own Span and LineColumn types. When this feature is enabled, rewriter instead uses the corresponding types from proc-macro2. This feature implies proc-macro2-impl below.

  • proc-macro2-impl: Implement the Span and LineColumn traits for the corresponding types in proc-macro2.

Comparison to TextEdit

The closest analogue to Rewriter of which we are aware is rust-analyzer's TextEdit.

The following are some notable differences:

  • Interface: One constructs a Rewriter from a &str, performs a series of rewrites, and then calls contents to obtain the resulting text as a String. By comparison, one constructs a TextEdit and then applys it to an &mut String.

  • Referring to text: Rewriter refers to text using Spans, which are composed of pairs of LineColumns. Each LineColumn contains a line and a column. By comparison, TextEdit refers to text using TextRanges, which are composed of pairs of TextSizes. Each TextSize wraps a u32 byte offset.

  • Stability: Rewriter aims to provide a stable interface. By comparison, users of the rust-analyzer crates are advised to pin versions or expect regular breaking changes.

About

Rust utilities for rewriting files

Topics

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages