本文へスキップ
製品デスクトップツールTASTECAD図面の確認TASTEFILESファイル管理TASTEFTPファイル転送TASTESSHリモートワークスペースTASTEZIP圧縮と展開TASTEWINMファイル管理開発ツールTASTECODERust 統合開発環境TASTESTUDIO統合開発・テスト環境TASTEETLデータ統合(ETL)サーバーTASTEREMOTEリモートデスクトップサーバーTASTEGEO空間情報サーバーTASTEMAILメールワークスペース投資TASTESTOCK株式自動売買デスクトップアプリはじめるダウンロードドキュメント購入すべての製品
マーケットプレイス
ニュース
技術ニュース今日の開発ニュース開発ドキュメントプログラミング言語RustTypeScriptJavaScriptPythonGoC#JavaCC++KotlinDartWebフロントエンド フレームワークNext.jsReactVue.js · NuxtSvelteKitAngularサーバー フレームワークSpring BootDjangoFastAPIASP.NET CoreNestJS · Expressアプリ・デスクトップ フレームワークTauriFlutterReact NativeElectronアルゴリズムアルゴリズムの基礎主要アルゴリズム発展アルゴリズム実務のアルゴリズム
コミュニティプロジェクト開発ログプロンプトAIツールの問題ショーケースコミュニティガイド
協業技術移転ウェブサイト構築デスクトップアプリ構築リリース・決済パイプライン販売パートナーお問い合わせ
サービスリモートデスクトップインストールパッケージのカスタマイズ
TASTEDEV
製品

デスクトップツール

TASTECAD複雑な図面を、軽やかにひらくTASTEFILES必要なファイルだけを、最速でTASTEFTPファイルが行き交う、いちばん端正な道TASTESSHサーバーとあなたを、より確かにつなぐTASTEZIPより速くまとめ、より安全にひらくTASTEWINM2つの画面で整理する、キーボード中心のファイルマネージャー

開発ツール

TASTECODERust アプリの編集・ビルド・デバッグ・テストまでひとつのウィンドウでTASTESTUDIO編集からリモートテスト、承認した AI 修正までTASTEETL値を見ながら、データを運ぶ

サーバー

TASTEREMOTE自社サーバーで運用するリモートデスクトップTASTEGEOGeoServer 互換の空間情報サーバーを Rust で作り直しますTASTEMAILメールの主導権を、もう一度自分の手に

投資

TASTESTOCKいつ・何を。自分で決めたルールどおりに動く株式自動売買

はじめる

ダウンロード全製品の最新版ドキュメント各製品の使い方購入サブスクリプション・永久ライセンスすべての製品全製品を一覧で
すべての製品
マーケットプレイスニュース
技術

ニュース

今日の開発ニュース言語・フレームワーク・GitHub・AI の公式発表開発ドキュメント言語・フレームワーク・アルゴリズムのガイド

プログラミング言語

RustTypeScriptJavaScriptPythonGoC#JavaCC++KotlinDart

フレームワーク

Webフロントエンド フレームワークNext.jsReactVue.js · NuxtSvelteKitAngular
サーバー フレームワークSpring BootDjangoFastAPIASP.NET CoreNestJS · Express
アプリ・デスクトップ フレームワークTauriFlutterReact NativeElectron

アルゴリズム

アルゴリズムの基礎計算量解析 · ソート · 探索 · 基本データ構造 · 木構造とヒープ主要アルゴリズムグラフ探索 · 最短経路と最小全域木 · 動的計画法 · 貪欲法 · 分割統治法 · バックトラッキング発展アルゴリズム文字列アルゴリズム · 数学と整数論 · ビット演算 · セグメント木 · Union-Find実務のアルゴリズムコーディング面接対策 · LRUキャッシュ · レート制限 · コンシステントハッシュ法
開発ドキュメントをすべて見る
コミュニティ
プロジェクトビルダーと作品を探す開発ログ決定と試行錯誤プロンプト再利用できる指示AIツールの問題Claude・Codex・Gemini の問題と回避策ショーケース完成した成果コミュニティガイドオープンにつくる方法
協業
技術移転Rust・egui でネイティブアプリを作るウェブサイト構築10言語、アカウント、ドキュメントとダウンロードデスクトップアプリ構築Rust・egui、WebView なしリリース・決済パイプライン署名・MSI・deb・rpm・AppImage・ハッシュ販売パートナー紹介して決済額の30%お問い合わせ構築・提携・投資のご相談
サービス
リモートデスクトップブラウザから自分のパソコンへインストールパッケージのカスタマイズ必要な機能だけ、設定は事前に
購入
JA
한국어EnglishDeutschEspañolFrançaisItalianoPortuguês (Brasil)日本語简体中文繁體中文
ログイン
ログイン
TASTEDEV

小さなツールから、より良い開発へ。

support@tastedev.netTASTEDEVを支援
製品製品ラインナップ購入ドキュメントダウンロードマーケットプレイスサポート
コミュニティプロジェクト開発ログプロンプトAIツールの問題ショーケース
ポリシー会社概要プライバシーポリシー利用規約サブスクリプション規約返金ポリシーコミュニティガイドライン
アカウントログイン新規登録
訪問者
今日
昨日
累計閲覧
商号
GXSOFT
代表者
CHOI YOUNG GU
事業者登録番号
853-44-00368
所在地
9F V24, 351 Gyeongin-ro, Michuhol-gu, Incheon, Republic of Korea
電話
+82-10-4404-1523
メール
whitecalvin@tastedev.net
個人情報保護責任者
CHOI YOUNG GU

© 2026 TASTEDEV製品情報は検証済みの開発ソースに基づいています。リリース・改善中

Rust ドキュメント
Rust
Getting Started with RustSyntax BasicsTypes and DataModules and PackagesErrors and TestingKey Concepts: Ownership, Borrowing, Lifetimes, Traits
ディスカッション

Rust ガイド · 3/6

Types and Data

この章は現在、英語でのみ提供しています。

Rust is statically typed: every value has a type known at compile time, and even numeric types never convert silently. This chapter tours the primitive types, the two kinds of strings, structs and enums, the everyday collections, and Option, Rust's answer to null.

Scalar types

KindTypesNotes
Signed integersi8 i16 i32 i64 i128 isizei32 is the default
Unsigned integersu8 u16 u32 u64 u128 usizeindexes and lengths use usize
Floating pointf32 f64f64 is the default
Booleanbooltrue or false
Charactercharone Unicode scalar value, 4 bytes

Integer overflow panics in debug builds and wraps around by default in release builds. When overflow is a real possibility, say what you mean with checked_add, wrapping_add or saturating_add. Conversions are explicit with as.

fn main() {
    let a: i32 = -42;
    let b: u8 = 255;
    let c = 3.14_f64;
    let ok: bool = true;
    let heart: char = '♥';
    println!("{a} {b} {c} {ok} {heart}");

    println!("{:?}", b.checked_add(1)); // None on overflow
    println!("{}", b.wrapping_add(1)); // 0, wraps around
    println!("{}", b.saturating_add(1)); // 255, clamps at the max

    let n = 300_i32 as u8; // 44, `as` truncates
    let avg = (7 as f64) / 2.0; // 3.5
    println!("{n} {avg}");
}

Compound types: tuples and arrays

A tuple groups a fixed number of values of different types; an array holds a fixed number of values of the same type. For a list that grows, use Vec, covered below.

fn main() {
    let point: (i32, f64, char) = (1, 2.5, 'x');
    let (x, y, z) = point; // destructuring
    println!("{x} {y} {z} / first field {}", point.0);

    let nums = [1, 2, 3, 4, 5];
    let zeros = [0u8; 4]; // four zeros
    let slice = &nums[1..3]; // [2, 3]
    println!("{} {:?} {:?}", nums.len(), zeros, slice);
}

Indexing past the end of an array panics instead of reading random memory. When an index might be out of range, use nums.get(10), which returns an .

この章について質問がありますか?
前の章Syntax Basics次の章Modules and Packages
Option

String versus &str

There are two main string types. String is an owned, growable, heap-allocated buffer. &str is a borrowed view into UTF-8 text that lives somewhere else; string literals are &'static str. Taking &str as a parameter lets callers pass either kind.

fn greet(name: &str) -> String {
    format!("Hello, {name}")
}

fn main() {
    let literal: &str = "Rust";
    let mut owned = String::from("Hello");
    owned.push_str(", world");
    owned.push('!');

    println!("{}", greet(literal));
    println!("{}", greet(&owned)); // &String coerces to &str

    let part: &str = &owned[0..5]; // "Hello"
    println!("{part}");

    // len() counts bytes; chars().count() counts characters
    println!("{} {}", "héllo".len(), "héllo".chars().count()); // 6 5
}

Strings are UTF-8, so s[0] is not allowed. Use chars() for characters, and keep range slices on character boundaries.

Structs and enums

A struct bundles related data under named fields. Methods live in an impl block: &self means the method only reads, &mut self means it modifies. Functions without self, like new, are associated functions and are called as Rect::new.

#[derive(Debug, Clone, PartialEq)]
struct Rect {
    width: u32,
    height: u32,
}

impl Rect {
    fn new(width: u32, height: u32) -> Self {
        Self { width, height }
    }
    fn area(&self) -> u32 {
        self.width * self.height
    }
    fn scale(&mut self, k: u32) {
        self.width *= k;
        self.height *= k;
    }
}

fn main() {
    let mut r = Rect::new(3, 4);
    println!("area {}", r.area()); // 12
    r.scale(2);
    println!("{r:?}"); // Rect { width: 6, height: 8 }
}

An enum models "exactly one of these", and each variant can carry its own data. Paired with match, the compiler makes sure every variant is handled.

enum Shape {
    Circle { radius: f64 },
    Square(f64),
    Point,
}

fn area(shape: &Shape) -> f64 {
    match shape {
        Shape::Circle { radius } => std::f64::consts::PI * radius * radius,
        Shape::Square(side) => side * side,
        Shape::Point => 0.0,
    }
}

fn main() {
    let shapes = [Shape::Circle { radius: 1.0 }, Shape::Square(2.0), Shape::Point];
    for s in &shapes {
        println!("{:.2}", area(s));
    }
}

Collections and Option

Rust has no null. A value that may be missing has type Option<T>, which is either Some(value) or None. You must deal with both cases before using the value, which rules out null-pointer errors entirely.

use std::collections::HashMap;

fn main() {
    let mut scores: Vec<i32> = Vec::new();
    scores.push(80);
    scores.push(95);
    let total: i32 = scores.iter().sum();
    println!("{scores:?} total {total}");
    println!("{:?}", scores.get(5)); // None

    let text = "the cat the dog the end";
    let mut counts: HashMap<&str, usize> = HashMap::new();
    for word in text.split_whitespace() {
        *counts.entry(word).or_insert(0) += 1;
    }

    match counts.get("the") {
        Some(n) => println!("the: {n} times"), // 3
        None => println!("not found"),
    }
    let birds = counts.get("bird").copied().unwrap_or(0);
    println!("bird: {birds} times"); // 0
}

Vec<T> is a growable array (also built with vec![1, 2, 3]). HashMap<K, V> maps keys to values; its entry API makes "insert or update" a one-liner. Combinators like map, unwrap_or and and_then often replace a full match on Option.

Summary

  • Numeric type names spell out size and signedness; convert explicitly with as.
  • String owns its text, &str borrows it; prefer &str for parameters.
  • Structs hold data plus impl methods; enums express "one of several cases".
  • Vec and HashMap are the workhorse collections, and Option replaces null.

コメント 0件

人気のコメント順新しい順

ログイン · ログインするとコメントできます。