rust - Can I mark a function as deprecated? -


i'd mark functions/methods deprecated. tried apply deprecated attribute:

#[deprecated] fn old_way_of_doing_it() { 

but yields error:

error: stability attributes may not used outside of standard library 

is there way in can have compiler warn consumer of library function deprecated?

i have no experience, i'm considering experimenting compiler plugins , custom attributes, guess require consumer use plugin, maybe unreasonable (or may unreasonable amount of work me implement?)

as side question out of curiosity, why deprecated attribute applicable standard library?

since rust 1.9.0 (2016 may 26th) can use #[deprecated] attribute in own crates (rfc 1270). syntax is:

#[deprecated(since="0.5.0", note="please use `new_method` instead")] pub fn old_method() { ..; } 

it throw following warning whenever use old_method:

<anon>:6:5: 6:15 warning: use of deprecated item: please use `new_method` instead, #[warn(deprecated)] on default <anon>:6     old_method()              ^~~~~~~~~~ 

you may find more information in rfc.


Comments

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

javascript - oscilloscope of speaker input stops rendering after a few seconds -