Add advanced_types example

This commit is contained in:
Timothy Warren 2019-02-08 14:40:38 -05:00
parent d2535d80a8
commit 9a23a0ce9b
5 changed files with 80 additions and 78 deletions

1
.idea/misc.xml generated
View File

@ -39,6 +39,7 @@
<cargoProject FILE="$PROJECT_DIR$/unsafe_blocks/Cargo.toml" />
<cargoProject FILE="$PROJECT_DIR$/advanced_lifetimes/Cargo.toml" />
<cargoProject FILE="$PROJECT_DIR$/advanced_traits/Cargo.toml" />
<cargoProject FILE="$PROJECT_DIR$/advanced_types/Cargo.toml" />
</component>
<component name="ComposerJsonPluginSettings">
<unboundedVersionInspectionSettings>

5
.idea/rust.iml generated
View File

@ -157,11 +157,16 @@
<sourceFolder url="file://$MODULE_DIR$/advanced_traits/examples" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/advanced_traits/tests" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/advanced_traits/benches" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/advanced_types/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/advanced_types/examples" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/advanced_types/tests" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/advanced_types/benches" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/add/add-one/target" />
<excludeFolder url="file://$MODULE_DIR$/add/adder/target" />
<excludeFolder url="file://$MODULE_DIR$/adder/target" />
<excludeFolder url="file://$MODULE_DIR$/advanced_lifetimes/target" />
<excludeFolder url="file://$MODULE_DIR$/advanced_traits/target" />
<excludeFolder url="file://$MODULE_DIR$/advanced_types/target" />
<excludeFolder url="file://$MODULE_DIR$/blog/target" />
<excludeFolder url="file://$MODULE_DIR$/branches/target" />
<excludeFolder url="file://$MODULE_DIR$/closures/target" />

129
.idea/workspace.xml generated
View File

@ -13,39 +13,16 @@
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="FileEditorManager">
<leaf>
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
<file pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/advanced_traits/src/main.rs">
<entry file="file://$PROJECT_DIR$/advanced_types/src/main.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="1221">
<caret line="147" column="4" selection-start-line="147" selection-start-column="4" selection-end-line="147" selection-end-column="4" />
<folding>
<element signature="e#444#445#0" expanded="true" />
<element signature="e#470#471#0" expanded="true" />
<element signature="e#793#794#0" expanded="true" />
<element signature="e#818#819#0" expanded="true" />
<element signature="e#898#899#0" expanded="true" />
<element signature="e#923#924#0" expanded="true" />
<element signature="e#965#966#0" expanded="true" />
<element signature="e#990#991#0" expanded="true" />
<element signature="e#1279#1280#0" expanded="true" />
<element signature="e#1308#1309#0" expanded="true" />
<element signature="e#1370#1371#0" expanded="true" />
<element signature="e#1399#1400#0" expanded="true" />
<element signature="e#2048#2049#0" expanded="true" />
<element signature="e#2071#2072#0" expanded="true" />
<element signature="e#2642#2643#0" expanded="true" />
<element signature="e#2665#2666#0" expanded="true" />
</folding>
<state relative-caret-position="256">
<caret line="16" selection-start-line="16" selection-end-line="16" />
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/advanced_traits/src/lib.rs">
<provider selected="true" editor-type-id="text-editor" />
</entry>
</file>
</leaf>
</component>
<component name="FileTemplateManagerImpl">
@ -75,7 +52,6 @@
<component name="IdeDocumentHistory">
<option name="CHANGED_PATHS">
<list>
<option value="$PROJECT_DIR$/modules/src/sound/instrument.rs" />
<option value="$PROJECT_DIR$/guessing_game/.gitignore" />
<option value="$PROJECT_DIR$/errors/src/main.rs" />
<option value="$PROJECT_DIR$/.gitignore" />
@ -126,6 +102,7 @@
<option value="$PROJECT_DIR$/advanced_lifetimes/src/main.rs" />
<option value="$PROJECT_DIR$/advanced_traits/src/lib.rs" />
<option value="$PROJECT_DIR$/advanced_traits/src/main.rs" />
<option value="$PROJECT_DIR$/advanced_types/src/main.rs" />
</list>
</option>
</component>
@ -135,11 +112,11 @@
<annotation-enable>false</annotation-enable>
<other-services-enabled>false</other-services-enabled>
</component>
<component name="ProjectFrameBounds" extendedState="6">
<component name="ProjectFrameBounds">
<option name="x" value="1920" />
<option name="y" value="582" />
<option name="width" value="1050" />
<option name="height" value="877" />
<option name="y" value="-438" />
<option name="width" value="1080" />
<option name="height" value="1897" />
</component>
<component name="ProjectLevelVcsManager" settingsEditedManually="true">
<ConfirmationsSetting value="1" id="Add" />
@ -149,28 +126,6 @@
<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="advanced_traits" type="9f88c78c:ScopeViewTreeModel$FileNode" />
</path>
<path>
<item name="rust" type="3d21c010:ScopeViewTreeModel$ProjectNode" />
<item name="rust" type="2674bda8:ScopeViewTreeModel$GroupNode" />
<item name="advanced_traits" type="9f88c78c:ScopeViewTreeModel$FileNode" />
<item name="src" type="9f88c78c:ScopeViewTreeModel$FileNode" />
</path>
</expand>
<select />
</subPane>
</pane>
<pane id="ProjectPane">
<subPane>
<expand>
@ -194,11 +149,33 @@
</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>
<path>
<item name="rust" type="3d21c010:ScopeViewTreeModel$ProjectNode" />
<item name="rust" type="2674bda8:ScopeViewTreeModel$GroupNode" />
<item name="advanced_types" type="9f88c78c:ScopeViewTreeModel$FileNode" />
</path>
<path>
<item name="rust" type="3d21c010:ScopeViewTreeModel$ProjectNode" />
<item name="rust" type="2674bda8:ScopeViewTreeModel$GroupNode" />
<item name="advanced_types" type="9f88c78c:ScopeViewTreeModel$FileNode" />
<item name="src" type="9f88c78c:ScopeViewTreeModel$FileNode" />
</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="1549564268156" />
<property name="com.android.tools.idea.instantapp.provision.ProvisionBeforeRunTaskProvider.myTimeStamp" value="1549652604126" />
<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" />
@ -226,7 +203,7 @@
</list>
</option>
</component>
<component name="RunManager" selected="Cargo Command.Run advanced_traits">
<component name="RunManager" selected="Cargo Command.Run advanced_types">
<configuration name="&lt;template&gt;" type="TestNG" default="true" selected="false">
<option name="MAIN_CLASS_NAME" />
<option name="VM_PARAMETERS" value="-ea" />
@ -265,13 +242,13 @@
<envs />
<method v="2" />
</configuration>
<configuration name="Run unsafe_blocks" type="CargoCommandRunConfiguration" factoryName="Cargo Command" temporary="true">
<configuration name="Run advanced_types" type="CargoCommandRunConfiguration" factoryName="Cargo Command" temporary="true">
<option name="channel" value="DEFAULT" />
<option name="command" value="run --package unsafe_blocks --bin unsafe_blocks" />
<option name="command" value="run --package advanced_types --bin advanced_types" />
<option name="allFeatures" value="false" />
<option name="nocapture" value="false" />
<option name="backtrace" value="SHORT" />
<option name="workingDirectory" value="file://$PROJECT_DIR$/unsafe_blocks" />
<option name="workingDirectory" value="file://$PROJECT_DIR$/advanced_types" />
<envs />
<method v="2" />
</configuration>
@ -304,11 +281,11 @@
</configuration>
<recent_temporary>
<list>
<item itemvalue="Cargo Command.Run advanced_types" />
<item itemvalue="Cargo Command.Run advanced_traits" />
<item itemvalue="Cargo Command.Run advanced_lifetimes" />
<item itemvalue="Cargo Command.Test lib::tests" />
<item itemvalue="Cargo Command.Test tests::it_works" />
<item itemvalue="Cargo Command.Run unsafe_blocks" />
</list>
</recent_temporary>
</component>
@ -348,8 +325,8 @@
<frame x="1920" y="-438" width="1080" height="1897" extended-state="6" />
<editor active="true" />
<layout>
<window_info content_ui="combo" id="Project" order="0" sideWeight="0.496614" visible="true" weight="0.2540132" />
<window_info id="Structure" order="1" sideWeight="0.503386" side_tool="true" visible="true" weight="0.2540132" />
<window_info active="true" content_ui="combo" id="Project" order="0" sideWeight="0.4958077" visible="true" weight="0.2540132" />
<window_info id="Structure" order="1" sideWeight="0.5041923" side_tool="true" visible="true" weight="0.2540132" />
<window_info id="Image Layers" order="2" />
<window_info id="Designer" order="3" />
<window_info id="Capture Tool" order="4" />
@ -357,7 +334,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 active="true" anchor="bottom" id="Run" order="2" visible="true" weight="0.2571269" />
<window_info anchor="bottom" id="Run" order="2" weight="0.2571269" />
<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" />
@ -379,13 +356,6 @@
<option name="version" value="1" />
</component>
<component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/modules/src/sound.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="16">
<caret line="1" lean-forward="true" selection-start-line="1" selection-end-line="1" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/modules/src/sound/instrument.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="48">
@ -634,9 +604,7 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/smart_pointers/src/lib.rs">
<provider selected="true" editor-type-id="text-editor" />
</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">
@ -807,13 +775,11 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/advanced_traits/src/lib.rs">
<provider selected="true" editor-type-id="text-editor" />
</entry>
<entry file="file://$PROJECT_DIR$/advanced_traits/src/lib.rs" />
<entry file="file://$PROJECT_DIR$/advanced_traits/src/main.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="1221">
<caret line="147" column="4" selection-start-line="147" selection-start-column="4" selection-end-line="147" selection-end-column="4" />
<state relative-caret-position="309">
<caret line="97" column="35" selection-start-line="97" selection-start-column="35" selection-end-line="97" selection-end-column="35" />
<folding>
<element signature="e#444#445#0" expanded="true" />
<element signature="e#470#471#0" expanded="true" />
@ -835,5 +801,12 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/advanced_types/src/main.rs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="256">
<caret line="16" selection-start-line="16" selection-end-line="16" />
</state>
</provider>
</entry>
</component>
</project>

View File

@ -0,0 +1,7 @@
[package]
name = "advanced_types"
version = "0.1.0"
authors = ["Timothy Warren <twarren@nabancard.com>"]
edition = "2018"
[dependencies]

View File

@ -0,0 +1,16 @@
// Type alias, just gives a new name to the existing type.
// Considered the same type, even using the new name
type Kilometers = i32;
// A type alias is much more useful for a long, complex type
type Thunk = Box<dyn Fn() + Send + 'static>;
fn main() {
let x: i32 = 5;
let y: Kilometers = 5;
println!("x + y = {}", x + y);
let f: Thunk = Box::new(|| println!("hi"));
f();
}