<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Vladimir Guguiev</title>
    <description>The latest articles on DEV Community by Vladimir Guguiev (@vovacodes).</description>
    <link>https://dev.to/vovacodes</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F557976%2Fa8394b4e-2d25-4583-9620-7e5ffc9bfedb.jpeg</url>
      <title>DEV Community: Vladimir Guguiev</title>
      <link>https://dev.to/vovacodes</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/vovacodes"/>
    <language>en</language>
    <item>
      <title>🦀 Publishing My First Rust Crate</title>
      <dc:creator>Vladimir Guguiev</dc:creator>
      <pubDate>Mon, 11 Jan 2021 20:49:51 +0000</pubDate>
      <link>https://dev.to/vovacodes/publishing-my-first-rust-crate-cni</link>
      <guid>https://dev.to/vovacodes/publishing-my-first-rust-crate-cni</guid>
      <description>&lt;p&gt;So, I've published &lt;a href="https://crates.io/crates/doctor"&gt;my first Rust crate&lt;/a&gt;. &lt;br&gt;
This post is a brief summary of my experience going through the process. There is no TLDR, because the whole post a TLDR, essentially.😛&lt;/p&gt;
&lt;h1&gt;
  
  
  🤗 Positive
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;The dev process is super smooth with tests that just work out of the box and require zero additional configuration.&lt;/li&gt;
&lt;li&gt;There are &lt;a href="https://rust-lang.github.io/api-guidelines/checklist.html"&gt;official guidelines&lt;/a&gt; documenting the API design best practices.&lt;/li&gt;
&lt;li&gt;Doc comments can (and should) include example code snippets that also &lt;a href="https://doc.rust-lang.org/rustdoc/documentation-tests.html"&gt;serve as additional tests&lt;/a&gt; for your crate's public API.&lt;/li&gt;
&lt;li&gt;The process of publishing is &lt;a href="https://doc.rust-lang.org/cargo/reference/publishing.html"&gt;well-documented&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Documentation is automatically generated for every published crate by &lt;a href="https://docs.rs/doctor"&gt;docs.rs&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;The release ritual can be automated with &lt;a href="https://github.com/sunng87/cargo-release"&gt;&lt;code&gt;cargo-release&lt;/code&gt;&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;h1&gt;
  
  
  😢 Negative
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;Need to keep a lot of things in mind to make sure your crate has great interoperability with the existing Rust ecosystem, e.g. because of the &lt;a href="https://github.com/Ixrec/rust-orphan-rules#what-are-the-orphan-rules"&gt;orphan rule&lt;/a&gt; the users of your crate won't be able to implement the traits defined in &lt;code&gt;std&lt;/code&gt; or &lt;code&gt;serde&lt;/code&gt; for the types from your crate, so you have to decide which ones it makes sense to implement and provide that implementation yourself.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/rust-lang/cargo/issues/2179"&gt;It is currently not possible&lt;/a&gt; to specify that a certain version of a crate implementing some &lt;code&gt;cargo-*&lt;/code&gt; subcommand must be installed when working on my crate. It's quite limiting, especially coming from JS where you can explicitly declare a cli package as a dependency of your own package and use it in build scripts, etc.&lt;/li&gt;
&lt;/ul&gt;
&lt;h1&gt;
  
  
  🤷🏻‍♂️ Confusing
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;Where should I put the main documentation for my crate? Should it be &lt;code&gt;README.md&lt;/code&gt; or a &lt;code&gt;//!&lt;/code&gt; doc comment in &lt;code&gt;src/lib.rs&lt;/code&gt;? Eventually, I ended up placing the crate documentation in &lt;code&gt;lib.rs&lt;/code&gt; and using &lt;a href="https://crates.io/crates/cargo-readme"&gt;&lt;code&gt;cargo-readme&lt;/code&gt;&lt;/a&gt; to extract it into &lt;code&gt;README.md&lt;/code&gt; whenever I publish a new release. It's cool that it's possible, but it's also an additional build step I have to care about. Don't know how people solve it usually, so please comment if you have a better workflow.&lt;/li&gt;
&lt;/ul&gt;
&lt;h1&gt;
  
  
  👨🏻‍🏫 Recommendations
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Use clippy with a config, as annoying as you can still handle. Mine is:&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="nd"&gt;#![warn(clippy::all,&lt;/span&gt; &lt;span class="nd"&gt;clippy::pedantic,&lt;/span&gt; &lt;span class="nd"&gt;clippy::nursery,&lt;/span&gt; &lt;span class="nd"&gt;clippy::cargo)]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;




&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Use &lt;a href="https://github.com/sunng87/cargo-release"&gt;&lt;code&gt;cargo-release&lt;/code&gt;&lt;/a&gt; and setup pre-release hooks and replacements.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Use &lt;a href="https://crates.io/crates/cargo-readme"&gt;&lt;code&gt;cargo-readme&lt;/code&gt;&lt;/a&gt; for extracting the crate documentation from &lt;code&gt;src/lib.rs&lt;/code&gt; into &lt;code&gt;README.md&lt;/code&gt;, thus avoiding duplicating it manually.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  🔮 Final thoughts
&lt;/h1&gt;

&lt;p&gt;Coming from a JS background and only recently starting dabbling in Rust I'd say the overall experience working on a Rust library is far more enjoyable than what you are going through authoring an npm package. &lt;br&gt;
This is, mostly, because the language itself comes with a bigger part of the tooling that you need to be productive. I really appreciate things like the built-in testing framework and excellent workflow around crate's documentation. At the same time, it doesn't feel like the &lt;code&gt;cargo&lt;/code&gt; ecosystem is fully matured yet, and certain things I'm used to having accessible in &lt;code&gt;npm&lt;/code&gt; world are missing (or maybe I'm just not aware of the alternatives).&lt;/p&gt;

&lt;p&gt;Anyways, I'd be happy to read your take on how to setup and maintain a crate in the comments, let me know what you think.&lt;/p&gt;

</description>
      <category>rust</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
