Check for overflows in fibonacci calculator
This commit is contained in:
parent
8fa802e1f7
commit
48b731f8fa
6
.idea/misc.xml
generated
6
.idea/misc.xml
generated
@ -47,6 +47,12 @@
|
||||
<cargoProject FILE="$PROJECT_DIR$/old_lady_who_swallowed_a_fly/Cargo.toml" />
|
||||
<cargoProject FILE="$PROJECT_DIR$/fibonacci/Cargo.toml" />
|
||||
<cargoProject FILE="$PROJECT_DIR$/factorial/Cargo.toml" />
|
||||
<cargoProject FILE="$PROJECT_DIR$/__non-book-expirements__/twelve_days_of_christmas/Cargo.toml" />
|
||||
<cargoProject FILE="$PROJECT_DIR$/__non-book-expirements__/old_lady_who_swallowed_a_fly/Cargo.toml" />
|
||||
<cargoProject FILE="$PROJECT_DIR$/__non-book-expirements__/ftoc/Cargo.toml" />
|
||||
<cargoProject FILE="$PROJECT_DIR$/__non-book-expirements__/fibonacci/Cargo.toml" />
|
||||
<cargoProject FILE="$PROJECT_DIR$/__non-book-expirements__/factorial/Cargo.toml" />
|
||||
<cargoProject FILE="$PROJECT_DIR$/__non-book-expirements__/ctof/Cargo.toml" />
|
||||
</component>
|
||||
<component name="ComposerJsonPluginSettings">
|
||||
<unboundedVersionInspectionSettings>
|
||||
|
30
.idea/rust.iml
generated
30
.idea/rust.iml
generated
@ -189,6 +189,36 @@
|
||||
<sourceFolder url="file://$MODULE_DIR$/factorial/examples" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/factorial/tests" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/factorial/benches" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/__non-book-expirements__/twelve_days_of_christmas/src" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/__non-book-expirements__/twelve_days_of_christmas/examples" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/__non-book-expirements__/twelve_days_of_christmas/tests" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/__non-book-expirements__/twelve_days_of_christmas/benches" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/__non-book-expirements__/old_lady_who_swallowed_a_fly/src" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/__non-book-expirements__/old_lady_who_swallowed_a_fly/examples" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/__non-book-expirements__/old_lady_who_swallowed_a_fly/tests" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/__non-book-expirements__/old_lady_who_swallowed_a_fly/benches" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/__non-book-expirements__/ftoc/src" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/__non-book-expirements__/ftoc/examples" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/__non-book-expirements__/ftoc/tests" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/__non-book-expirements__/ftoc/benches" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/__non-book-expirements__/fibonacci/src" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/__non-book-expirements__/fibonacci/examples" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/__non-book-expirements__/fibonacci/tests" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/__non-book-expirements__/fibonacci/benches" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/__non-book-expirements__/factorial/src" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/__non-book-expirements__/factorial/examples" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/__non-book-expirements__/factorial/tests" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/__non-book-expirements__/factorial/benches" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/__non-book-expirements__/ctof/src" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/__non-book-expirements__/ctof/examples" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/__non-book-expirements__/ctof/tests" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/__non-book-expirements__/ctof/benches" isTestSource="true" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/__non-book-expirements__/ctof/target" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/__non-book-expirements__/factorial/target" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/__non-book-expirements__/fibonacci/target" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/__non-book-expirements__/ftoc/target" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/__non-book-expirements__/old_lady_who_swallowed_a_fly/target" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/__non-book-expirements__/twelve_days_of_christmas/target" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/add/add-one/target" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/add/adder/target" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/adder/target" />
|
||||
|
366
.idea/workspace.xml
generated
366
.idea/workspace.xml
generated
@ -2,18 +2,10 @@
|
||||
<project version="4">
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="c8f42924-1cd2-4b1c-bcff-602a3368bb16" name="Default Changelist" comment="">
|
||||
<change beforePath="$PROJECT_DIR$/.idea/vcs.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/vcs.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/misc.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/misc.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/rust.iml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/rust.iml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/ctof/.gitignore" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/ctof/Cargo.toml" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/ctof/src/main.rs" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/factorial/Cargo.toml" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/factorial/src/main.rs" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/fibonacci/Cargo.toml" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/fibonacci/src/main.rs" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/ftoc/.gitignore" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/ftoc/Cargo.toml" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/ftoc/src/main.rs" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/__non-book-expirements__/fibonacci/src/main.rs" beforeDir="false" afterPath="$PROJECT_DIR$/__non-book-expirements__/fibonacci/src/main.rs" afterDir="false" />
|
||||
</list>
|
||||
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
@ -22,7 +14,26 @@
|
||||
<option name="LAST_RESOLUTION" value="IGNORE" />
|
||||
</component>
|
||||
<component name="FileEditorManager">
|
||||
<leaf />
|
||||
<leaf>
|
||||
<file pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/__non-book-expirements__/factorial/src/main.rs">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="1008">
|
||||
<caret line="63" selection-start-line="63" selection-end-line="63" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file pinned="false" current-in-tab="true">
|
||||
<entry file="file://$PROJECT_DIR$/__non-book-expirements__/fibonacci/src/main.rs">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="896">
|
||||
<caret line="56" column="35" selection-start-line="56" selection-start-column="35" selection-end-line="56" selection-end-column="35" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
</leaf>
|
||||
</component>
|
||||
<component name="FileTemplateManagerImpl">
|
||||
<option name="RECENT_TEMPLATES">
|
||||
@ -54,7 +65,6 @@
|
||||
<component name="IdeDocumentHistory">
|
||||
<option name="CHANGED_PATHS">
|
||||
<list>
|
||||
<option value="$PROJECT_DIR$/minigrep_v2/src/lib.rs" />
|
||||
<option value="$PROJECT_DIR$/add/Cargo.toml" />
|
||||
<option value="$PROJECT_DIR$/add/adder/src/main.rs" />
|
||||
<option value="$PROJECT_DIR$/add/add-one/Cargo.toml" />
|
||||
@ -105,6 +115,7 @@
|
||||
<option value="$PROJECT_DIR$/fibonacci/src/main.rs" />
|
||||
<option value="$PROJECT_DIR$/factorial/Cargo.toml" />
|
||||
<option value="$PROJECT_DIR$/factorial/src/main.rs" />
|
||||
<option value="$PROJECT_DIR$/__non-book-expirements__/fibonacci/src/main.rs" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
@ -115,10 +126,10 @@
|
||||
<other-services-enabled>false</other-services-enabled>
|
||||
</component>
|
||||
<component name="ProjectFrameBounds" extendedState="6">
|
||||
<option name="x" value="1949" />
|
||||
<option name="y" value="-372" />
|
||||
<option name="width" value="1073" />
|
||||
<option name="height" value="1837" />
|
||||
<option name="x" value="1680" />
|
||||
<option name="y" value="-410" />
|
||||
<option name="width" value="1050" />
|
||||
<option name="height" value="1027" />
|
||||
</component>
|
||||
<component name="ProjectLevelVcsManager" settingsEditedManually="true">
|
||||
<ConfirmationsSetting value="1" id="Add" />
|
||||
@ -128,6 +139,35 @@
|
||||
<foldersAlwaysOnTop value="true" />
|
||||
</navigator>
|
||||
<panes>
|
||||
<pane id="Scope">
|
||||
<subPane subId="Scope 'Project Files'; set:Project Files; class com.intellij.psi.search.scope.ProjectFilesScope">
|
||||
<expand>
|
||||
<path>
|
||||
<item name="rust" type="3d21c010:ScopeViewTreeModel$ProjectNode" />
|
||||
<item name="rust" type="2674bda8:ScopeViewTreeModel$GroupNode" />
|
||||
</path>
|
||||
<path>
|
||||
<item name="rust" type="3d21c010:ScopeViewTreeModel$ProjectNode" />
|
||||
<item name="rust" type="2674bda8:ScopeViewTreeModel$GroupNode" />
|
||||
<item name="__non-book-expirements__" type="9f88c78c:ScopeViewTreeModel$FileNode" />
|
||||
</path>
|
||||
<path>
|
||||
<item name="rust" type="3d21c010:ScopeViewTreeModel$ProjectNode" />
|
||||
<item name="rust" type="2674bda8:ScopeViewTreeModel$GroupNode" />
|
||||
<item name="__non-book-expirements__" type="9f88c78c:ScopeViewTreeModel$FileNode" />
|
||||
<item name="fibonacci" type="9f88c78c:ScopeViewTreeModel$FileNode" />
|
||||
</path>
|
||||
<path>
|
||||
<item name="rust" type="3d21c010:ScopeViewTreeModel$ProjectNode" />
|
||||
<item name="rust" type="2674bda8:ScopeViewTreeModel$GroupNode" />
|
||||
<item name="__non-book-expirements__" type="9f88c78c:ScopeViewTreeModel$FileNode" />
|
||||
<item name="fibonacci" type="9f88c78c:ScopeViewTreeModel$FileNode" />
|
||||
<item name="src" type="9f88c78c:ScopeViewTreeModel$FileNode" />
|
||||
</path>
|
||||
</expand>
|
||||
<select />
|
||||
</subPane>
|
||||
</pane>
|
||||
<pane id="ProjectPane">
|
||||
<subPane>
|
||||
<expand>
|
||||
@ -151,22 +191,11 @@
|
||||
</subPane>
|
||||
</pane>
|
||||
<pane id="PackagesPane" />
|
||||
<pane id="Scope">
|
||||
<subPane subId="Scope 'Project Files'; set:Project Files; class com.intellij.psi.search.scope.ProjectFilesScope">
|
||||
<expand>
|
||||
<path>
|
||||
<item name="rust" type="3d21c010:ScopeViewTreeModel$ProjectNode" />
|
||||
<item name="rust" type="2674bda8:ScopeViewTreeModel$GroupNode" />
|
||||
</path>
|
||||
</expand>
|
||||
<select />
|
||||
</subPane>
|
||||
</pane>
|
||||
</panes>
|
||||
</component>
|
||||
<component name="PropertiesComponent">
|
||||
<property name="JavaScriptWeakerCompletionTypeGuess" value="true" />
|
||||
<property name="com.android.tools.idea.instantapp.provision.ProvisionBeforeRunTaskProvider.myTimeStamp" value="1550864691211" />
|
||||
<property name="com.android.tools.idea.instantapp.provision.ProvisionBeforeRunTaskProvider.myTimeStamp" value="1551207113796" />
|
||||
<property name="javascript.nodejs.core.library.configured.version" value="7.1.0" />
|
||||
<property name="js.eslint.eslintPackage" value="$USER_HOME$/.yarn-config/global/node_modules/.bin/eslint" />
|
||||
<property name="js.eslint.nodeInterpreter" value="project" />
|
||||
@ -200,7 +229,7 @@
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="RunManager" selected="Cargo Command.Run factorial">
|
||||
<component name="RunManager" selected="Cargo Command.Run fibonacci (1)">
|
||||
<configuration name="<template>" type="TestNG" default="true" selected="false">
|
||||
<option name="MAIN_CLASS_NAME" />
|
||||
<option name="VM_PARAMETERS" value="-ea" />
|
||||
@ -229,6 +258,16 @@
|
||||
<envs />
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
<configuration name="Run fibonacci (1)" type="CargoCommandRunConfiguration" factoryName="Cargo Command" temporary="true">
|
||||
<option name="channel" value="DEFAULT" />
|
||||
<option name="command" value="run --package fibonacci --bin fibonacci" />
|
||||
<option name="allFeatures" value="false" />
|
||||
<option name="nocapture" value="false" />
|
||||
<option name="backtrace" value="SHORT" />
|
||||
<option name="workingDirectory" value="file://$PROJECT_DIR$/__non-book-expirements__/fibonacci" />
|
||||
<envs />
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
<configuration name="Run fibonacci" type="CargoCommandRunConfiguration" factoryName="Cargo Command" temporary="true">
|
||||
<option name="channel" value="DEFAULT" />
|
||||
<option name="command" value="run --package fibonacci --bin fibonacci" />
|
||||
@ -259,16 +298,6 @@
|
||||
<envs />
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
<configuration name="Run pancakes" type="CargoCommandRunConfiguration" factoryName="Cargo Command" temporary="true">
|
||||
<option name="channel" value="DEFAULT" />
|
||||
<option name="command" value="run --package pancakes --bin pancakes" />
|
||||
<option name="allFeatures" value="false" />
|
||||
<option name="nocapture" value="false" />
|
||||
<option name="backtrace" value="SHORT" />
|
||||
<option name="workingDirectory" value="file://$PROJECT_DIR$/pancakes" />
|
||||
<envs />
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
<configuration default="true" type="JUnit" factoryName="JUnit">
|
||||
<option name="TEST_OBJECT" value="class" />
|
||||
<option name="WORKING_DIRECTORY" value="$MODULE_DIR$" />
|
||||
@ -278,11 +307,11 @@
|
||||
</configuration>
|
||||
<recent_temporary>
|
||||
<list>
|
||||
<item itemvalue="Cargo Command.Run fibonacci (1)" />
|
||||
<item itemvalue="Cargo Command.Run factorial" />
|
||||
<item itemvalue="Cargo Command.Run fibonacci" />
|
||||
<item itemvalue="Cargo Command.Run old_lady_who_swallowed_a_fly" />
|
||||
<item itemvalue="Cargo Command.Run hello" />
|
||||
<item itemvalue="Cargo Command.Run pancakes" />
|
||||
</list>
|
||||
</recent_temporary>
|
||||
</component>
|
||||
@ -319,10 +348,11 @@
|
||||
</history-entry>
|
||||
</component>
|
||||
<component name="ToolWindowManager">
|
||||
<frame x="1920" y="-438" width="1080" height="1897" extended-state="6" />
|
||||
<frame x="1680" y="-410" width="1050" height="1657" extended-state="6" />
|
||||
<editor active="true" />
|
||||
<layout>
|
||||
<window_info active="true" content_ui="combo" id="Project" order="0" sideWeight="0.4941308" visible="true" weight="0.2540132" />
|
||||
<window_info id="Structure" order="1" sideWeight="0.5058692" side_tool="true" visible="true" weight="0.2540132" />
|
||||
<window_info content_ui="combo" id="Project" order="0" sideWeight="0.48962656" visible="true" weight="0.31212723" />
|
||||
<window_info id="Structure" order="1" sideWeight="0.5103735" side_tool="true" visible="true" weight="0.31212723" />
|
||||
<window_info id="Image Layers" order="2" />
|
||||
<window_info id="Designer" order="3" />
|
||||
<window_info id="Capture Tool" order="4" />
|
||||
@ -330,7 +360,7 @@
|
||||
<window_info id="Cargo" order="6" sideWeight="0.49791494" weight="0.3286119" />
|
||||
<window_info anchor="bottom" id="Message" order="0" />
|
||||
<window_info anchor="bottom" id="Find" order="1" weight="0.32979318" />
|
||||
<window_info anchor="bottom" id="Run" order="2" weight="0.22207876" />
|
||||
<window_info active="true" anchor="bottom" id="Run" order="2" visible="true" weight="0.22207876" />
|
||||
<window_info anchor="bottom" id="Debug" order="3" weight="0.4" />
|
||||
<window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
|
||||
<window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
|
||||
@ -346,88 +376,13 @@
|
||||
<window_info anchor="right" id="Theme Preview" order="3" />
|
||||
<window_info anchor="right" id="Capture Analysis" order="4" />
|
||||
<window_info anchor="right" id="Palette	" order="5" />
|
||||
<window_info anchor="right" id="SciView" order="6" />
|
||||
</layout>
|
||||
</component>
|
||||
<component name="TypeScriptGeneratedFilesManager">
|
||||
<option name="version" value="1" />
|
||||
</component>
|
||||
<component name="editorHistoryManager">
|
||||
<entry file="file://$PROJECT_DIR$/minigrep_v2/src/lib.rs">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="624">
|
||||
<caret line="39" selection-start-line="39" selection-end-line="39" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/add/adder/src/main.rs">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="64">
|
||||
<caret line="4" column="77" selection-start-line="4" selection-start-column="77" selection-end-line="4" selection-end-column="77" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/add/add-one/Cargo.toml">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="112">
|
||||
<caret line="7" selection-start-line="7" selection-end-line="7" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/add/adder/Cargo.toml">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="144">
|
||||
<caret line="9" selection-start-line="9" selection-end-line="9" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/add/add-one/src/lib.rs">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="240">
|
||||
<caret line="15" lean-forward="true" selection-start-line="15" selection-end-line="15" />
|
||||
<folding>
|
||||
<element signature="e#30#31#0" expanded="true" />
|
||||
<element signature="e#40#41#0" expanded="true" />
|
||||
<element signature="e#87#88#0" expanded="true" />
|
||||
<element signature="e#123#124#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/smart_pointers/src/lib.rs" />
|
||||
<entry file="file://$PROJECT_DIR$/smart_pointers/src/main.rs">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="256">
|
||||
<caret line="16" column="4" selection-start-line="16" selection-start-column="4" selection-end-line="16" selection-end-column="4" />
|
||||
<folding>
|
||||
<element signature="e#68#69#0" expanded="true" />
|
||||
<element signature="e#91#92#0" expanded="true" />
|
||||
<element signature="e#200#201#0" expanded="true" />
|
||||
<element signature="e#351#352#0" expanded="true" />
|
||||
<element signature="e#433#434#0" expanded="true" />
|
||||
<element signature="e#244#245#0" expanded="true" />
|
||||
<element signature="e#261#262#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/reference_counting/src/main.rs">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="448">
|
||||
<caret line="28" lean-forward="true" selection-start-line="28" selection-end-line="28" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/interior_mutability/src/lib.rs">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="679">
|
||||
<caret line="55" column="69" selection-start-line="55" selection-start-column="69" selection-end-line="55" selection-end-column="69" />
|
||||
<folding>
|
||||
<element signature="e#1104#1105#0" expanded="true" />
|
||||
<element signature="e#1144#1145#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/reference_cycles/src/main.rs">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="768">
|
||||
@ -449,26 +404,7 @@
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/twelve_days_of_christmas/Cargo.toml">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="32">
|
||||
<caret line="2" column="13" selection-start-line="2" selection-start-column="13" selection-end-line="2" selection-end-column="13" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/oop/src/lib.rs">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="720">
|
||||
<caret line="45" lean-forward="true" selection-start-line="45" selection-end-line="45" />
|
||||
<folding>
|
||||
<element signature="e#510#511#0" expanded="true" />
|
||||
<element signature="e#537#538#0" expanded="true" />
|
||||
<element signature="e#956#957#0" expanded="true" />
|
||||
<element signature="e#992#993#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/twelve_days_of_christmas/Cargo.toml" />
|
||||
<entry file="file://$PROJECT_DIR$/gui/Cargo.toml">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="112">
|
||||
@ -494,19 +430,6 @@
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/blog/src/lib.rs">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="672">
|
||||
<caret line="42" column="1" selection-start-line="42" selection-start-column="1" selection-end-line="42" selection-end-column="1" />
|
||||
<folding>
|
||||
<element signature="e#240#241#0" expanded="true" />
|
||||
<element signature="e#268#269#0" expanded="true" />
|
||||
<element signature="e#656#657#0" expanded="true" />
|
||||
<element signature="e#699#700#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/blog/Cargo.toml">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="112">
|
||||
@ -514,13 +437,6 @@
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/blog/src/main.rs">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="208">
|
||||
<caret line="13" selection-start-line="13" selection-end-line="13" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/pattern_matching/src/main.rs">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="2752">
|
||||
@ -528,13 +444,6 @@
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/unsafe_blocks/src/main.rs">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="448">
|
||||
<caret line="28" column="50" selection-start-line="28" selection-start-column="50" selection-end-line="28" selection-end-column="50" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/advanced_lifetimes/src/main.rs">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="304">
|
||||
@ -680,17 +589,6 @@
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/hello/src/lib.rs">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="400">
|
||||
<caret line="25" column="39" selection-start-line="25" selection-start-column="39" selection-end-line="25" selection-end-column="39" />
|
||||
<folding>
|
||||
<element signature="e#194#195#0" expanded="true" />
|
||||
<element signature="e#211#212#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/hello/src/bin/main.rs">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="768">
|
||||
@ -698,13 +596,7 @@
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/twelve_days_of_christmas/src/main.rs">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="752">
|
||||
<caret line="47" selection-start-line="47" selection-end-line="47" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/twelve_days_of_christmas/src/main.rs" />
|
||||
<entry file="file://$PROJECT_DIR$/loops/src/main.rs">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="944">
|
||||
@ -731,10 +623,106 @@
|
||||
<entry file="file://$PROJECT_DIR$/ftoc/src/main.rs" />
|
||||
<entry file="file://$PROJECT_DIR$/factorial/src/main.rs" />
|
||||
<entry file="file://$PROJECT_DIR$/fibonacci/Cargo.toml" />
|
||||
<entry file="file://$PROJECT_DIR$/old_lady_who_swallowed_a_fly/src/main.rs">
|
||||
<entry file="file://$PROJECT_DIR$/old_lady_who_swallowed_a_fly/src/main.rs" />
|
||||
<entry file="file://$PROJECT_DIR$/__non-book-expirements__/old_lady_who_swallowed_a_fly/src/main.rs">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="1184">
|
||||
<caret line="74" lean-forward="true" selection-start-line="74" selection-end-line="74" />
|
||||
<state relative-caret-position="896">
|
||||
<caret line="56" column="8" selection-start-line="56" selection-start-column="8" selection-end-line="56" selection-end-column="8" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/__non-book-expirements__/twelve_days_of_christmas/src/main.rs">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="272">
|
||||
<caret line="17" column="37" selection-start-line="17" selection-start-column="37" selection-end-line="17" selection-end-column="37" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/__non-book-expirements__/ftoc/src/main.rs">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="320">
|
||||
<caret line="22" lean-forward="true" selection-start-line="22" selection-end-line="22" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/__non-book-expirements__/ctof/src/main.rs">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="320">
|
||||
<caret line="22" lean-forward="true" selection-start-line="22" selection-end-line="22" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/structs/src/main.rs">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="624">
|
||||
<caret line="39" lean-forward="true" selection-start-line="39" selection-end-line="39" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/unsafe_blocks/src/main.rs">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="960">
|
||||
<caret line="60" column="4" selection-start-line="60" selection-start-column="4" selection-end-line="60" selection-end-column="4" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/blog/src/lib.rs">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="528">
|
||||
<caret line="35" lean-forward="true" selection-start-line="35" selection-end-line="35" />
|
||||
<folding>
|
||||
<element signature="e#240#241#0" expanded="true" />
|
||||
<element signature="e#268#269#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/blog/src/main.rs">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="208">
|
||||
<caret line="13" selection-start-line="13" selection-end-line="13" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/lifetimes/src/main.rs">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="864">
|
||||
<caret line="56" selection-start-line="56" selection-end-line="56" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/oop/src/lib.rs">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="688">
|
||||
<caret line="45" lean-forward="true" selection-start-line="45" selection-end-line="45" />
|
||||
<folding>
|
||||
<element signature="e#956#957#0" expanded="true" />
|
||||
<element signature="e#992#993#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/hello/src/lib.rs">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="-47">
|
||||
<caret line="25" column="39" selection-start-line="25" selection-start-column="39" selection-end-line="25" selection-end-column="39" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/adder/src/lib.rs">
|
||||
<provider selected="true" editor-type-id="text-editor" />
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/__non-book-expirements__/factorial/src/main.rs">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="1008">
|
||||
<caret line="63" selection-start-line="63" selection-end-line="63" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/__non-book-expirements__/fibonacci/src/main.rs">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="896">
|
||||
<caret line="56" column="35" selection-start-line="56" selection-start-column="35" selection-end-line="56" selection-end-column="35" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
|
@ -3,23 +3,29 @@ extern crate separator;
|
||||
use separator::Separatable;
|
||||
|
||||
use std::io;
|
||||
use std::u128;
|
||||
|
||||
///! Calculate a number in the fibonnacci sequence,
|
||||
///! using a lookup table for better worst-case performance.
|
||||
///
|
||||
/// Can calculate up to 186 using native unsigned 128 bit integers.
|
||||
fn fibonacci(n: usize, table: &mut Vec<u128>) -> u128 {
|
||||
fn fibonacci(n: usize, table: &mut Vec<u128>) -> Option<u128> {
|
||||
match table.get(n) {
|
||||
Some(x) => *x, // Vec<T>.get returns a Option with a reference to the value, so deref
|
||||
Some(x) => Some(*x), // Vec<T>.get returns a Option with a reference to the value, so deref
|
||||
None => {
|
||||
let a = n - 1;
|
||||
let b = n - 2;
|
||||
let a = fibonacci(n - 1, table)
|
||||
.unwrap_or(u128::MAX);
|
||||
let b = fibonacci(n - 2, table)
|
||||
.unwrap_or(u128::MAX);
|
||||
|
||||
let current = fibonacci(a, table) + fibonacci(b, table);
|
||||
// Check for overflow when adding
|
||||
let attempt = a.checked_add(b);
|
||||
|
||||
table.insert(n, current);
|
||||
if let Some(current) = attempt {
|
||||
table.insert(n, current);
|
||||
}
|
||||
|
||||
current
|
||||
attempt
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -44,9 +50,16 @@ fn main() {
|
||||
Err(_) => break, // Exit on non-number
|
||||
};
|
||||
|
||||
let calculated = fibonacci(index, &mut table);
|
||||
|
||||
println!("Calculating number for index: {}", index);
|
||||
println!("The Fibonnacci number at index: {} is {}", index, calculated.separated_string());
|
||||
|
||||
match fibonacci(index, &mut table) {
|
||||
Some(calculated) => {
|
||||
println!("The Fibonacci number at index: {} is {}", index, calculated.separated_string());
|
||||
},
|
||||
None => {
|
||||
println!("Calculation overflow. The factorial base was too large.");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user