0

Is there a standard shorthand for importing rust's actix-web framework (like how numpy is always imported as np or matplotlib.pyplot is always imported as mpl in python)? actix_web::... is a bit much to write out each time.

Pioneer_11
  • 670
  • 4
  • 19
  • Possibly duplicate? https://stackoverflow.com/questions/50999616/how-to-idiomatically-alias-a-crate-in-rust-2018 – Jared Smith Aug 31 '23 at 14:09
  • I don't think so, but writing really isn't a concern with code, it's by far more often read than written. It's not all that common to rename crates in the Rust ecosystem in my experience. – cafce25 Aug 31 '23 at 14:09
  • 2
    @JaredSmith I don't think so, that answers *how* to rename a crate, not *what* `actix_web` is commonly renamed to. – cafce25 Aug 31 '23 at 14:11
  • 1
    @cafce25 yeah, that's why I just posted the comment instead of VTC. – Jared Smith Aug 31 '23 at 14:12
  • 1
    @JaredSmith as cafce says I'm looking for what to rename it to rather than how to rename it but thanks (and +1) for asking rather than an immediate VTC – Pioneer_11 Aug 31 '23 at 14:50
  • @Pioneer_11 good deal. There is no commonly used alias like that. That being said, if you are using rust-analyzer with a good editor/IDE autocomplete should work *extremely* well: Rust has a way better toolchain than most languages. You shouldn't have to write more the the first character or two of the package/sub-package/function at each step in the fully qualified name. – Jared Smith Aug 31 '23 at 14:54
  • 1
    @JaredSmith true but it's still a decently long package name that pops up everywhere in web applications, it would be nice to have a shorter alias. – Pioneer_11 Sep 01 '23 at 13:16

0 Answers0