<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>emre şahin's digital garden 🍃 - cargo</title>
    <link>https://emresahin.net/tags/cargo/</link>
    <description>Posts in the cargo tag</description>
    <language>en</language>
    <managingEditor>contact@emresahin.net (Emre Şahin)</managingEditor>
    <lastBuildDate>Tue, 29 Sep 2026 14:57:43 +0000</lastBuildDate>
    <atom:link href="https://emresahin.net/tags/cargo/rss.xml" rel="self" type="application/rss+xml"/>
    <item>
      <title>Devlog 10: Codecov, Doctests, and Cargo Publish Struggles</title>
      <published>2025-01-19T09:30:49+00:00</published>
      <updated>2025-01-19T09:30:49+00:00</updated>
      <author>Emre Şahin</author>
      <pubDate>Sun, 19 Jan 2025 09:30:49 +0000</pubDate>
      <link>https://emresahin.net/devlog-10/</link>
      <guid isPermaLink="true">https://emresahin.net/devlog-10/</guid>
      <description>🐢 Now we’re going into the real deep work. The only failure was the Codecov patch in Xvc. Let’s see what needs to be done. 🐇 It looks, from the coverage page , that our additions to HStore don’t have any tests. We can add some unit tests to new joins, maybe. 🐢 I don’t find unit tests particularly...</description>
      <category>Devlog</category>
      <category>XVC</category>
      <category>Rust</category>
      <category>cargo</category>
      <category>ecs</category>
      <category>Claude</category>
      <category>cargo-publish</category>
      <category>crates.io</category>
      <category>sqlite</category>
      <category>codecov</category>
      <category>doctests</category>
      <content:encoded><![CDATA[<p>🐢 Now we’re going into the real deep work. The only failure was the Codecov patch in Xvc. Let’s see what needs to be done.</p>
<p>🐇 It looks, from the <a href="https://app.codecov.io/gh/iesahin/xvc/pull/263?src=pr&amp;el=tree&amp;utm_medium=referral&amp;utm_source=github&amp;utm_content=comment&amp;utm_campaign=pr+comments&amp;utm_term=Emre+Sahin">coverage page</a>, that our additions to HStore don’t have any tests. We can add some unit tests to new joins, maybe.</p>
<p>🐢 I don’t find unit tests particularly useful, but let’s use GitHub Copilot to add tests for us.</p>
<p>🐇 Added a unit test and a doc test for <code>full_join</code>, and I think doc tests have more value. They provide documentation, and we can readily see how to use a function from its docs. Better to increase coverage with doc tests.</p>
<p>🐢 There are points that I should learn while writing doc tests. The imports must use the full path, not <code>crate::</code>. The tested struct also doesn’t have implicit imports.</p>
<p>🐇 The ceremony of adding keys and values is a bit too much. It may be worthwhile to add <code>insert</code> for any <code>Into&lt;XvcEntity&gt;</code>.</p>
<p>🐢 It will certainly save time if we don’t have to type <code>.into()</code> for each key :)</p>
<p>🐇 Pushed to test again. Should we have some means to test coverage locally?</p>
<p>🐢 I don’t think we need to consider coverage locally. It’s not worth our time.</p>
<p>🐇 Now while waiting for tests to be completed, what can we do?</p>
<pre><code>gh -R iesahin/xvc run list
completed	failure	v0.6.13	Rust-CI	v0.6.13	pull_request	12543831360	3m54s	2024-12-30T08:15:06Z
...
</code></pre>
<p>🐢 I don’t think it took too much time. Let’s view the results:</p>
<pre><code>gh -R iesahin/xvc run view 12543831360
...
  X Run Current Dev Tests
...
To see what failed, try: 
View this run on GitHub: https://github.com/iesahin/xvc/actions/runs/12543831360
</code></pre>
<p>🐢 The current dev tests fail for some reason. Let’s run these locally.</p>
<p>🐇 We’re missing <code>llvm-tools-preview</code> locally. How do we install this?</p>
<p>🐢 The command is:</p>
<pre><code>rustup component add llvm-tools-preview
info: component 'llvm-tools' for target 'aarch64-apple-darwin' is up to date
</code></pre>
<p>🐇 It’s already installed. We need to set the environment variables.</p>
<p>🐢 Instead, we can just turn off dev tests for the time being. We don’t need them. Our local tests pass.</p>
<p>🐇 Yeah, ok, we don’t need to solve each and every bit of these issues.</p>
<pre><code>gh -R iesahin/xvc run list
</code></pre>
<p>…
🐇 Ok. Let’s take a look at the run again.</p>
<pre><code>gh -R iesahin/xvc run list
completed	failure	v0.6.13	Rust-CI	v0.6.13	pull_request	12544020064	3m39s	2024-12-30T08:33:25Z

gh -R iesahin/xvc run view 12544020064
...
  X Test and Coverage
...

gh run view 12544020064 --log-failed
...
Test and Coverage (stable)	Test and Coverage	2024-12-30T08:36:58.8911690Z Error: ProcessError { stdout: "", stderr: "  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current\n                                 Dload  Upload   Total   Spent    Left  Speed\n\r  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0\r  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0\ncurl: (7) Failed to connect to e1.xvc.dev port 80 after 160 ms: Couldn't connect to server\n" }
...
</code></pre>
<p>🐢 We need to start <code>nginx</code> on the server. We forgot it yesterday.</p>
<p>🐇 Ah, yeah. After adding that dufs installation. Ok.</p>
<p>🐢 We also need to add a reverse proxy to dufs somehow, but this is for later.</p>
<p>🐇 For the use case, I don’t think it’s necessary. We can just adjust the port to a non-standard one if we need to use 443 for another thing, but let’s take a look at the tests again.</p>
<p>🐢 Let’s add another doc test. This time to <code>XvcStore</code>.</p>
<pre><code>cargo test -p xvc-ecs --doc
...
test result: ok. 8 passed; 0 failed; 1 ignored; 0 measured; 0 filtered out; finished in 2.87s
</code></pre>
<p>🐇 Sent the files again. Waiting for tests to finish.</p>
<p>🐢 Let’s check the keymaps file in the meantime.</p>
<p>🐇 I tried to read some documentation but didn’t see an error. Maybe we should just set it to non-lazy and avoid allowing remaps.</p>
<p>🐢 We already spent too much time with this.</p>
<p>🐇 Yes, let’s take a look at the tests again.</p>
<pre><code>gh -R iesahin/xvc run list
completed	success	v0.6.13	Rust-CI	v0.6.13	pull_request	12544291068	8m10s	2024-12-30T09:00:42Z
...
</code></pre>
<p>🐢 Oh, yeah, the merge is ready.</p>
<p>🐇 Patch coverage is still behind the target, though.</p>
<p>🐢 Yeah, but let’s release this one and make the next better covered. Also, I’m not sure if the doc tests had any effect on coverage.</p>
<p>🐇 If we look at the <a href="https://app.codecov.io/gh/iesahin/xvc/pull/263?src=pr&amp;el=tree&amp;utm_medium=referral&amp;utm_source=github&amp;utm_content=comment&amp;utm_campaign=pr+comments&amp;utm_term=Emre+Sahin">coverage page</a> again, we can see if the doc tests had any effect.</p>
<p>🐢 It seems codecov.io doesn’t consider coverage for doc tests. This is a bit weird, but let’s not spend more time on this.</p>
<p>🐇 Sure, let’s merge.</p>
<p>🐢 I think we forgot to bump the version in <code>Cargo.toml</code>. We’ll have to do that in main.</p>
<p>🐇 Oh, yeah. Let’s bump it and tag as well.</p>
<p>🐢 Now, we can wait for all files to be produced. What will we do next?</p>
<p>🐇 We can just release the Python version as well. It shouldn’t need any changes.</p>
<p>🐢 Umm, right. Maybe we can add a few tests as well.</p>
<p>🐇 Let’s bump the version first and see.</p>
<p>🐢 Bumped versions in <code>Cargo.toml</code> and ran <code>maturin develop</code>.</p>
<p>🐇 It seems ready now.</p>
<p>🐢 The main fails, though. The “Publish Crates” action looks for <code>libsqlite3</code>. Let’s take a look at it.</p>
<pre><code>gh -R iesahin/xvc run list
completed	failure	Release v0.6.13	Publish Crates	v0.6.13	push	12544753359	6m1s	2024-12-30T09:41:56Z
</code></pre>
<p>🐢 The issue is that the VM doesn’t have <code>libsqlite3-dev</code>. Let’s add it.</p>
<p>🐇 We need to start the job manually again. Let’s not tag this time.</p>
<p>🐢 Some of the packages were already published. Now they break. <code>crates.io</code> says they’re already published. Maybe we can check if a package is already published.</p>
<p>🐇 Let’s check if we can make <code>cargo publish</code> more forgiving.</p>
<p>🐢 There doesn’t seem to be an option. Let’s search “how to skip published packages in the workspace to avoid errors with cargo publish”.</p>
<p>🐇 Claude is bullshitting again. Let’s try a manual approach: how to skip already published packages.</p>
<p>🐢 It may be easier to just add a check if the package is published. How do we get the info?</p>
<p>🐇 Or we can just go on to the next package if the package is already available.</p>
<p>🐢 Let’s do this manually this time.</p>]]></content:encoded>
    </item>
    <item>
      <title>Feature flags in Rust</title>
      <published>2022-10-01T14:09:00+00:00</published>
      <updated>2022-10-01T14:09:00+00:00</updated>
      <author>Emre Şahin</author>
      <pubDate>Sat, 01 Oct 2022 14:09:00 +0000</pubDate>
      <link>https://emresahin.net/Feature-flags-in-Rust/</link>
      <guid isPermaLink="true">https://emresahin.net/Feature-flags-in-Rust/</guid>
      <description>Rust allows you to define feature flags to compile certain parts of a binary conditionally. The Cargo Book has an extensive section on them. The Cargo.toml file can have a [features] section. In this section, features can be defined, and they can enable other features. [features] my-feature = [] ...</description>
      <category>Rust</category>
      <category>Software Development</category>
      <category>Rust</category>
      <category>Cargo</category>
      <category>Feature Flags</category>
      <category>Conditional Compilation</category>
      <category>Configuration</category>
      <content:encoded><![CDATA[<p>Rust allows you to define feature flags to compile certain parts of a binary conditionally.
The Cargo Book has an extensive <a href="https://doc.rust-lang.org/cargo/reference/features.html">section</a> on them.</p>
<p>The <code>Cargo.toml</code> file can have a <code>[features]</code> section.
In this section, features can be defined, and they can enable other features.</p>
<pre><code class="language-toml">[features]
my-feature = []
another-feature = ["my-feature"]
</code></pre>
<p>These markers are used in the code as follows:</p>
<pre><code class="language-rust">
#[cfg(feature = "my-feature")]
pub mod my_module;
</code></pre>
<p>The default features are listed under the <code>default</code> key of the <code>[features]</code> section.
If it’s not defined, it’s considered empty, so <code>cargo build</code> supplies no features to the build system by default.</p>
<p>If you don’t want <code>default</code> features added automatically, you can use the <code>--no-default-features</code> option with <code>cargo</code>.</p>
<p>Starting from Rust 1.60, dependencies can be tied to features.
When you define a dependency in the <code>[dependencies]</code> section, add <code>optional = true</code> to its options. Then, in <code>[features]</code>, use the <code>dep:package</code> syntax.</p>
<pre><code class="language-toml">
[dependencies]

pack = { version = "1.0", optional = true }

[features]

my-feature = ["dep:pack"]
</code></pre>
<p>This way, Cargo doesn’t compile <code>pack</code> if <code>my-feature</code> is not enabled.</p>
<p>A caveat to using features is that they should be additive.
There shouldn’t be a <code>no-std</code> feature to remove the standard library dependency; instead, you should define a <code>std</code> feature and enable it by default.
The reason behind this is that Cargo ensures there is a single copy of a package with <em>all</em> the requested features enabled for the entire dependency graph.
If you have a <code>no-x</code> feature that removes functionality, it breaks the additive logic of Cargo’s feature resolution.</p>]]></content:encoded>
    </item>
  </channel>
</rss>
