Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Alkass committed Jul 31, 2024
1 parent 6e96872 commit 0df5307
Show file tree
Hide file tree
Showing 16 changed files with 2,185 additions and 2,234 deletions.
Empty file added .nojekyll
Empty file.
6 changes: 2 additions & 4 deletions 404/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@
<meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1.0'>


<meta name="description" content="Sorry, we can’t find that page that you’re looking for. You can try again by going back to the homepage.
" />
<meta property="og:description" content="Sorry, we can’t find that page that you’re looking for. You can try again by going back to the homepage.
" />
<meta name="description" content="Technology Excellence Redefined">
<meta property="og:description" content="Technology Excellence Redefined" />

<meta name="author" content="IQDevs" />

Expand Down
10 changes: 5 additions & 5 deletions Constructors-and-Destructors-in-C/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ <h2 id="constructors">Constructors</h2>
<div class="language-c highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="cp">#ifndef STACK_H
#define STACK_H
</span>
<span class="cp">#include &lt;stdio.h&gt; // printf
#include &lt;stdlib.h&gt; // calloc &amp; free
#include &lt;stdbool.h&gt; // true &amp; false
<span class="cp">#include</span> <span class="cpf">&lt;stdio.h&gt;</span><span class="c1"> // printf</span><span class="cp">
#include</span> <span class="cpf">&lt;stdlib.h&gt;</span><span class="c1"> // calloc &amp; free</span><span class="cp">
#include</span> <span class="cpf">&lt;stdbool.h&gt;</span><span class="c1"> // true &amp; false</span><span class="cp">
</span>
<span class="cp">#define STACK_CAP 12
</span>
Expand Down Expand Up @@ -138,8 +138,8 @@ <h2 id="constructors">Constructors</h2>

<p>Now the following program:</p>

<div class="language-c highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="cp">#include &lt;stdio.h&gt;
#include "header.h"
<div class="language-c highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="cp">#include</span> <span class="cpf">&lt;stdio.h&gt;</span><span class="cp">
#include</span> <span class="cpf">"header.h"</span><span class="cp">
</span>
<span class="kt">int</span> <span class="nf">main</span><span class="p">()</span> <span class="p">{</span>
<span class="n">printf</span><span class="p">(</span><span class="s">"Inside main</span><span class="se">\n</span><span class="s">"</span><span class="p">);</span>
Expand Down
4 changes: 2 additions & 2 deletions Crafting-Code-1/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,13 @@ <h1>Crafting Code - Building Common Interfaces</h1>

<p>And that’ll require the user to import his/her desired function or set of functions as needed. This is fine, but wouldn’t it be better if you could provide only one function that does all these operations? We’re going to call this function a common interface, but this procedure is called a passthrough in the professional field. A passthrough function is a multi-purpose entry point to a set of different classes or functions. In the case of our Math library, we could have our passthrough function written as follows:</p>

<div class="language-rust highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">fn</span> <span class="nf">passthrough</span><span class="p">(</span><span class="n">operation</span><span class="p">:</span> <span class="o">&amp;</span><span class="nv">'static</span> <span class="nb">str</span><span class="p">,</span> <span class="n">op1</span><span class="p">:</span> <span class="nb">f32</span><span class="p">,</span> <span class="n">op2</span><span class="p">:</span> <span class="nb">f32</span><span class="p">)</span> <span class="k">-&gt;</span> <span class="nb">f32</span> <span class="p">{</span>
<div class="language-rust highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">fn</span> <span class="nf">passthrough</span><span class="p">(</span><span class="n">operation</span><span class="p">:</span> <span class="o">&amp;</span><span class="k">'static</span> <span class="nb">str</span><span class="p">,</span> <span class="n">op1</span><span class="p">:</span> <span class="nb">f32</span><span class="p">,</span> <span class="n">op2</span><span class="p">:</span> <span class="nb">f32</span><span class="p">)</span> <span class="k">-&gt;</span> <span class="nb">f32</span> <span class="p">{</span>
<span class="k">return</span> <span class="k">match</span> <span class="n">operation</span> <span class="p">{</span>
<span class="s">"+"</span> <span class="k">=&gt;</span> <span class="nf">add</span><span class="p">(</span><span class="n">op1</span><span class="p">,</span> <span class="n">op2</span><span class="p">),</span>
<span class="s">"-"</span> <span class="k">=&gt;</span> <span class="nf">sub</span><span class="p">(</span><span class="n">op1</span><span class="p">,</span> <span class="n">op2</span><span class="p">),</span>
<span class="s">"*"</span> <span class="k">=&gt;</span> <span class="nf">mul</span><span class="p">(</span><span class="n">op1</span><span class="p">,</span> <span class="n">op2</span><span class="p">),</span>
<span class="s">"/"</span> <span class="k">=&gt;</span> <span class="nf">div</span><span class="p">(</span><span class="n">op1</span><span class="p">,</span> <span class="n">op2</span><span class="p">),</span>
<span class="mi">_</span> <span class="k">=&gt;</span> <span class="mi">0</span> <span class="k">as</span> <span class="nb">f32</span><span class="p">,</span> <span class="c">//Return 0 if unknown operation. Near future bug alert!!!</span>
<span class="n">_</span> <span class="k">=&gt;</span> <span class="mi">0</span> <span class="k">as</span> <span class="nb">f32</span><span class="p">,</span> <span class="c1">//Return 0 if unknown operation. Near future bug alert!!!</span>
<span class="p">};</span>
<span class="p">}</span>
</code></pre></div></div>
Expand Down
30 changes: 15 additions & 15 deletions Enum-and-Match-Systems-in-Rust/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,10 @@ <h1>Enum and Match Systems in Rust</h1>
<span class="p">}</span>

<span class="k">fn</span> <span class="nf">compute_results</span><span class="p">()</span> <span class="k">-&gt;</span> <span class="n">FunctionStatus</span> <span class="p">{</span>
<span class="c">// Successful execution would look like the following:</span>
<span class="c">// return FunctionStatus::PASS("Everything looks good".to_string());</span>
<span class="c1">// Successful execution would look like the following:</span>
<span class="c1">// return FunctionStatus::PASS("Everything looks good".to_string());</span>

<span class="c">// While a failure would be indicated as follows:</span>
<span class="c1">// While a failure would be indicated as follows:</span>
<span class="k">return</span> <span class="nn">FunctionStatus</span><span class="p">::</span><span class="nf">FAILURE</span><span class="p">(</span><span class="nn">SeverityStatus</span><span class="p">::</span><span class="nf">FATAL</span><span class="p">(</span><span class="s">"Continuing beyond this point will cause more damage to the hardware"</span><span class="nf">.to_string</span><span class="p">()));</span>
<span class="p">}</span>
</code></pre></div></div>
Expand All @@ -128,18 +128,18 @@ <h1>Enum and Match Systems in Rust</h1>
<span class="k">let</span> <span class="n">res</span> <span class="o">=</span> <span class="nf">compute_results</span><span class="p">();</span>
<span class="k">match</span> <span class="n">res</span> <span class="p">{</span>
<span class="nn">FunctionStatus</span><span class="p">::</span><span class="nf">PASS</span><span class="p">(</span><span class="n">x</span><span class="p">)</span> <span class="k">=&gt;</span> <span class="p">{</span>
<span class="c">// Handling a PASS response</span>
<span class="c1">// Handling a PASS response</span>
<span class="nd">println!</span><span class="p">(</span><span class="s">"PASS: {}"</span><span class="p">,</span> <span class="n">x</span><span class="p">);</span>
<span class="p">}</span>
<span class="nn">FunctionStatus</span><span class="p">::</span><span class="nf">FAILURE</span><span class="p">(</span><span class="n">x</span><span class="p">)</span> <span class="k">=&gt;</span> <span class="p">{</span>
<span class="c">// Handling a FAILURE response</span>
<span class="c1">// Handling a FAILURE response</span>
<span class="k">match</span> <span class="n">x</span> <span class="p">{</span>
<span class="nn">SeverityStatus</span><span class="p">::</span><span class="nf">BENIGN</span><span class="p">(</span><span class="n">y</span><span class="p">)</span> <span class="k">=&gt;</span> <span class="p">{</span>
<span class="c">// Handling a BENIGN FAILURE response</span>
<span class="c1">// Handling a BENIGN FAILURE response</span>
<span class="nd">println!</span><span class="p">(</span><span class="s">"BENIGN: {}"</span><span class="p">,</span> <span class="n">y</span><span class="p">);</span>
<span class="p">}</span>
<span class="nn">SeverityStatus</span><span class="p">::</span><span class="nf">FATAL</span><span class="p">(</span><span class="n">y</span><span class="p">)</span> <span class="k">=&gt;</span> <span class="p">{</span>
<span class="c">// Handling a FATAL FAILURE response</span>
<span class="c1">// Handling a FATAL FAILURE response</span>
<span class="nd">println!</span><span class="p">(</span><span class="s">"FATAL: {}"</span><span class="p">,</span> <span class="n">y</span><span class="p">);</span>
<span class="p">}</span>
<span class="p">};</span>
Expand All @@ -165,8 +165,8 @@ <h1>Enum and Match Systems in Rust</h1>
<span class="p">}</span>
<span class="p">};</span>
<span class="p">}</span>
<span class="mi">_</span> <span class="k">=&gt;</span> <span class="p">{</span>
<span class="c">// Here goes the handling of "everything else", or it can be left out completely</span>
<span class="n">_</span> <span class="k">=&gt;</span> <span class="p">{</span>
<span class="c1">// Here goes the handling of "everything else", or it can be left out completely</span>
<span class="p">}</span>
<span class="p">};</span>
<span class="p">}</span>
Expand All @@ -184,15 +184,15 @@ <h1>Enum and Match Systems in Rust</h1>
<span class="nn">SeverityStatus</span><span class="p">::</span><span class="nf">FATAL</span><span class="p">(</span><span class="n">message</span><span class="p">)</span> <span class="k">=&gt;</span> <span class="p">{</span>
<span class="nd">println!</span><span class="p">(</span><span class="s">"FATAL: {}"</span><span class="p">,</span> <span class="n">message</span><span class="p">);</span>
<span class="p">}</span>
<span class="nn">SeverityStatus</span><span class="p">::</span><span class="nf">BENIGN</span><span class="p">(</span><span class="mi">_</span><span class="p">)</span> <span class="k">=&gt;</span> <span class="p">{</span>
<span class="c">// Leaving this case unhandled</span>
<span class="c">// NOTE: you can't print _. If you change your mind and decide to</span>
<span class="c">// actually handle this case, replace `_` with a valid variable name.</span>
<span class="nn">SeverityStatus</span><span class="p">::</span><span class="nf">BENIGN</span><span class="p">(</span><span class="n">_</span><span class="p">)</span> <span class="k">=&gt;</span> <span class="p">{</span>
<span class="c1">// Leaving this case unhandled</span>
<span class="c1">// NOTE: you can't print _. If you change your mind and decide to</span>
<span class="c1">// actually handle this case, replace `_` with a valid variable name.</span>
<span class="p">}</span>
<span class="p">};</span>
<span class="p">}</span>
<span class="nn">FunctionStatus</span><span class="p">::</span><span class="nf">PASS</span><span class="p">(</span><span class="mi">_</span><span class="p">)</span> <span class="k">=&gt;</span> <span class="p">{</span>
<span class="c">// Leaving this case unhandled</span>
<span class="nn">FunctionStatus</span><span class="p">::</span><span class="nf">PASS</span><span class="p">(</span><span class="n">_</span><span class="p">)</span> <span class="k">=&gt;</span> <span class="p">{</span>
<span class="c1">// Leaving this case unhandled</span>
<span class="p">}</span>
<span class="p">};</span>
<span class="p">}</span>
Expand Down
Loading

0 comments on commit 0df5307

Please sign in to comment.