<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>unit | Learn C Games Programming Blog</title>
	<atom:link href="https://learncgames.com/tag/unit/feed/" rel="self" type="application/rss+xml" />
	<link>https://learncgames.com</link>
	<description>A blog about C, programming games and my ebook(s).</description>
	<lastBuildDate>Sun, 16 Feb 2025 13:32:20 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://learncgames.com/wp-content/uploads/2020/03/cropped-favicon-32x32.png</url>
	<title>unit | Learn C Games Programming Blog</title>
	<link>https://learncgames.com</link>
	<width>32</width>
	<height>32</height>
</image> 
<site xmlns="com-wordpress:feed-additions:1">181446779</site>	<item>
		<title>Rust&#8217;s way of importing from other modules is bizarre</title>
		<link>https://learncgames.com/rusts-way-of-importing-from-other-modules-is-bizarre/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=rusts-way-of-importing-from-other-modules-is-bizarre</link>
		
		<dc:creator><![CDATA[David]]></dc:creator>
		<pubDate>Mon, 17 Feb 2025 00:05:17 +0000</pubDate>
				<category><![CDATA[Rust]]></category>
		<category><![CDATA[Techniques]]></category>
		<category><![CDATA[Delphi]]></category>
		<category><![CDATA[Struct]]></category>
		<category><![CDATA[unit]]></category>
		<guid isPermaLink="false">https://learncgames.com/?p=3298</guid>

					<description><![CDATA[<p>I come from a background of Pascal and Delphi. From about 1989 Turbo Pascal 4 and subsequently Delphi had a really useful unit system for breaking a program down into multiple source files. A unit is the equivalent of Rust&#8217;s mod.  Anything you wish to export from a unit is put in the interface section [&#8230;]</p>
The post <a href="https://learncgames.com/rusts-way-of-importing-from-other-modules-is-bizarre/">Rust’s way of importing from other modules is bizarre</a> first appeared on <a href="https://learncgames.com">Learn C Games Programming Blog</a>.]]></description>
										<content:encoded><![CDATA[<p>I come from a background of Pascal and Delphi. From about 1989 Turbo Pascal 4 and subsequently Delphi had a really useful unit system for breaking a program down into multiple source files. A unit is the equivalent of Rust&#8217;s mod.  Anything you wish to export from a unit is put in the interface section of the source file- consts, types, functions etc. Like making them pub in Rust. Then in the source file that wants to use these, you just put <em>using name-of-unit</em>. No hassles, very easy to use and it just works.</p>
<p>Now in Rust, they have a cockermanie system.  I had a main.rs that had several Structs (Card and Game) and decided to put it in another file poker.rs inside a mod poker {.</p>
<p>I made both Structs pub.  When compiling, there&#8217;s no errors in poker.rs but in the main.rs which has</p>
<pre><code class="language-rust" data-line="">pub mod poker;
use poker::{Card, Game};</code></pre>
<p>There&#8217;s red lines under Card and Game.</p>
<p>note:<em> struct `crate::poker::poker::Card` exists but is inaccessible</em> etc. Grrr.</p>
<p><img fetchpriority="high" decoding="async" class="alignleft wp-image-3299 size-full" src="https://learncgames.com/wp-content/uploads/2025/02/poker.png" alt="Rust compile errors" width="509" height="232" srcset="https://learncgames.com/wp-content/uploads/2025/02/poker.png 509w, https://learncgames.com/wp-content/uploads/2025/02/poker-300x137.png 300w" sizes="(max-width: 509px) 100vw, 509px" /></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>Now, no doubt there is soime way to make this work but why make it so difficult?</p>The post <a href="https://learncgames.com/rusts-way-of-importing-from-other-modules-is-bizarre/">Rust’s way of importing from other modules is bizarre</a> first appeared on <a href="https://learncgames.com">Learn C Games Programming Blog</a>.]]></content:encoded>
					
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">3298</post-id>	</item>
	</channel>
</rss>
