Rust specific ligatures
I would like to request ligatures for Rust for the following symbols:
#[]::<>
Hi, I love getting requests for new ligatures! 😄 I'm not familiar with Rust, so just to confirm, these are both examples of opening/closing tags that would usually have other text placed between the brackets, right? So the ligature part would only be #[ and ::<, respectively? And what is the expected appearance of both of these ligatures? I assume it would be the # horizontal lines extending to the right to connect with the edge of the bracket, and the :: shifting upward to align vertically with <?
Hi @heathercran, here's an example of #[]
For more context of what these things look like in context:
::<...>
This is used to annotate the type of a function which is generic over a type. For example:
let x = (0..10).sum::<i64>(); // x is a 64-bit signed integer
let y = (0..10).sum::<u8>(); // y is an 8-bit unsigned integer
When a trait is generic over a type, the annotation is slightly different:
let x: u8 = 5;
let y = Into::<u64>::into(x);
Note that this is a slightly construed example, but it showcases how to annotates both functions and traits.
In all cases, the argument within the angle brackets (<...>) can be really anything, including types which themselves can be generic over additional types within. For example:
foo_bar::<Arc<Option<u64>>>()
SomeTrait::<Arc<Option<u64>>>::foo_bar()
If a ligature is going to be added to the opening portion ::<, there should be a corresponding one to the closing side too >::. There also should be balance whether ::< is closed by > or >::.
#[...]
This is used for attributes to be read by the compiler. Most typically, for conditional compilation based on feature flags, target operating system, or to toggle lints. It comes in two variants:
// This applies to the whole module
#![enable(clippy::all)]
// This applies to the next unit of code
#[disable(clippy::some_lint)]
fn main() { ... }
A ligature for #[ is nice, and I think it could be cool to have a ligature for #![ (though I don't know what that would look like).
A ligature for
#[is nice, and I think it could be cool to have a ligature for#![(though I don't know what that would look like).
My version is that is just the #[ ligature but the double bars are extended and the ! is imposed on top of it with a negative space outline.
@heathercran drew beautiful ligatures for both #[] and ::<>. Those are shipped in 1.2.
However the #![ was requested after we already shipped it, so that's going to wait for a future release. 💖
#![ ligature was added in version 1.3!