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

Feature Request: Completion for class function that is not inherent method #18584

Open
hehaoqian opened this issue Dec 1, 2024 · 1 comment
Labels
A-completion autocompletion C-feature Category: feature request

Comments

@hehaoqian
Copy link

According to Rust API guidelines,

Smart pointers do not add inherent methods (C-SMART-PTR)

Therefore, smart pointer structs, such as Box, Arc
have many class function that is not method,
and the first parameter is the type itself
such as Box::into_raw, Arc::into_inner

pub fn into_raw(b: Box<T, A>) -> *mut T

pub fn into_inner(this: Arc<T, A>) -> Option<T>

Is it possible to add these functions to completion, when I press the period character after the object variable?
The functions can be limited to the function whose first parameter is Self, &Self, &mut Self
For example

let foo = Arc::new(1);
let bar = foo.

Is it possible to show Arc::into_inner in the completion list?
When the completion is accepted, the code is automatically rewritten to

let foo = Arc::new(1);
let bar = Arc::into_inner(foo);
@hehaoqian hehaoqian added the C-feature Category: feature request label Dec 1, 2024
@ChayimFriedman2
Copy link
Contributor

I think we should postfix-complete any methods taking a variation of Self as a first parameter, not just for smart pointers.

@ChayimFriedman2 ChayimFriedman2 added the A-completion autocompletion label Dec 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-completion autocompletion C-feature Category: feature request
Projects
None yet
Development

No branches or pull requests

2 participants