Skip to main content

Module targets

Module targets 

Source
Expand description

This module implements Cargo conventions for directory layout:

  • src/lib.rs is a library
  • src/main.rs is a binary
  • src/bin/*.rs are binaries
  • examples/*.rs are examples
  • tests/*.rs are integration tests
  • benches/*.rs are benchmarks

It is a bit tricky because we need match explicit information from Cargo.toml with implicit info in directory layout.

Re-exportsยง

use cargo_util::collections::HashMap; ๐Ÿ”’
use cargo_util::collections::HashSet; ๐Ÿ”’
use std::fmt::Write; ๐Ÿ”’
use std::fs; ๐Ÿ”’
use std::fs::DirEntry; ๐Ÿ”’
use std::path::Path; ๐Ÿ”’
use std::path::PathBuf; ๐Ÿ”’
use anyhow::Context as _; ๐Ÿ”’
use cargo_util::paths; ๐Ÿ”’
use cargo_util_schemas::core::CrateType; ๐Ÿ”’
use cargo_util_schemas::manifest::PathValue; ๐Ÿ”’
use cargo_util_schemas::manifest::StringOrVec; ๐Ÿ”’
use cargo_util_schemas::manifest::TomlBenchTarget; ๐Ÿ”’
use cargo_util_schemas::manifest::TomlBinTarget; ๐Ÿ”’
use cargo_util_schemas::manifest::TomlExampleTarget; ๐Ÿ”’
use cargo_util_schemas::manifest::TomlLibTarget; ๐Ÿ”’
use cargo_util_schemas::manifest::TomlManifest; ๐Ÿ”’
use cargo_util_schemas::manifest::TomlPackageBuild; ๐Ÿ”’
use cargo_util_schemas::manifest::TomlTarget; ๐Ÿ”’
use cargo_util_schemas::manifest::TomlTestTarget; ๐Ÿ”’
use crate::compiler::rustdoc::RustdocScrapeExamples; ๐Ÿ”’
use crate::util::closest_msg; ๐Ÿ”’
use crate::util::errors::CargoResult; ๐Ÿ”’
use crate::util::restricted_names; ๐Ÿ”’
use crate::workspace::parser::deprecated_underscore; ๐Ÿ”’
use crate::workspace::Edition; ๐Ÿ”’
use crate::workspace::Feature; ๐Ÿ”’
use crate::workspace::Features; ๐Ÿ”’
use crate::workspace::Target; ๐Ÿ”’

Constantsยง

DEFAULT_BENCH_DIR_NAME ๐Ÿ”’
DEFAULT_EXAMPLE_DIR_NAME ๐Ÿ”’
DEFAULT_TEST_DIR_NAME ๐Ÿ”’
TARGET_KIND_BENCH ๐Ÿ”’
TARGET_KIND_BIN ๐Ÿ”’
TARGET_KIND_EXAMPLE ๐Ÿ”’
TARGET_KIND_HUMAN_BENCH ๐Ÿ”’
TARGET_KIND_HUMAN_BIN ๐Ÿ”’
TARGET_KIND_HUMAN_EXAMPLE ๐Ÿ”’
TARGET_KIND_HUMAN_LIB ๐Ÿ”’
TARGET_KIND_HUMAN_TEST ๐Ÿ”’
TARGET_KIND_LIB ๐Ÿ”’
TARGET_KIND_TEST ๐Ÿ”’

Functionsยง

are_normalized ๐Ÿ”’
are_normalized_ ๐Ÿ”’
configure ๐Ÿ”’
infer_any ๐Ÿ”’
infer_file ๐Ÿ”’
infer_from_directory ๐Ÿ”’
infer_subdirectory ๐Ÿ”’
inferred_bins ๐Ÿ”’
inferred_lib ๐Ÿ”’
inferred_to_toml_targets ๐Ÿ”’
is_normalized ๐Ÿ”’
is_not_dotfile ๐Ÿ”’
legacy_bin_path ๐Ÿ”’
name_or_panic ๐Ÿ”’
normalize_benches
normalize_bins
normalize_build
Returns the path to the build script if one exists for this crate.
normalize_examples
normalize_lib
normalize_targets ๐Ÿ”’
normalize_targets_with_legacy_path ๐Ÿ”’
normalize_tests
target_path ๐Ÿ”’
target_path_not_found_error_message ๐Ÿ”’
Build an error message for a target path that cannot be determined either by auto-discovery or specifying.
to_bench_targets ๐Ÿ”’
to_bin_targets ๐Ÿ”’
to_example_targets ๐Ÿ”’
to_lib_target ๐Ÿ”’
to_targets ๐Ÿ”’
to_test_targets ๐Ÿ”’
toml_targets_and_inferred ๐Ÿ”’
validate_bin_crate_types ๐Ÿ”’
validate_bin_name ๐Ÿ”’
validate_bin_proc_macro ๐Ÿ”’
validate_build_name ๐Ÿ”’
validate_crate_types ๐Ÿ”’
validate_lib_name ๐Ÿ”’
validate_proc_macro ๐Ÿ”’
validate_target_name ๐Ÿ”’
validate_unique_build_scripts ๐Ÿ”’
Will check a list of build scripts, and make sure script file stems are unique within a vector.
validate_unique_names ๐Ÿ”’
Will check a list of toml targets, and make sure the target names are unique within a vector.