Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rust specific ligatures #257

Open
Rhelvetican opened this issue Oct 2, 2024 · 4 comments
Open

Rust specific ligatures #257

Rhelvetican opened this issue Oct 2, 2024 · 4 comments
Milestone

Comments

@Rhelvetican
Copy link

I would like to request ligatures for Rust for the following symbols:

  • #[]
  • ::<>
@heathercran
Copy link
Collaborator

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 <?

@Rhelvetican
Copy link
Author

Hi @heathercran, here's an example of #[]
image

@JP-Ellis
Copy link

JP-Ellis commented Jan 14, 2025

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).

@Rhelvetican
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

No branches or pull requests

3 participants