Skip to main content

Bot

Struct Bot 

Source
pub struct Bot { /* private fields */ }
Expand description

A handle to the bot for async tasks: cheap to clone, Send + Sync.

Reads of the per-tick snapshot (Bot::pose, Bot::health, …) are synchronous. Everything that touches the world, the inventory or the server goes through Bot::with (or a helper built on it) and runs inside the tick.

Handles work best in tasks the Ext executor polls (Ext::new, Bot::spawn): those resume within the same tick. A handle moved into a task of another executor (e.g. a tokio task reading stdin) works too, one tick later.

Implementations§

Source§

impl Bot

Source

pub async fn dig(&self, pos: BlockPos) -> Result<(), Error>

Digs the block at pos: selects the fastest hotbar tool, turns until the server has the crosshair on the block (aim first), then holds the left button for the vanilla dig time (tool, efficiency, haste / fatigue, water, not on ground) and releases it once the block is gone. The player should stand still meanwhile.

Fails with Error::NothingToDig (air), Error::Unbreakable, Error::OutOfReach, Error::LostTarget, Error::Teleported / Error::Died or Error::Timeout. The client predicts the broken block as air; if the server disagrees it sends the block back (see Bot::block_at).

use ghast_client::BlockPos;
bot.dig(BlockPos::new(2, 64, 0)).await?;
Source

pub async fn dig_with( &self, pos: BlockPos, opts: DigOptions, ) -> Result<(), Error>

Bot::dig with options.

use ghast_client::{BlockPos, Face};
use ghast_ext::DigOptions;
bot.dig_with(BlockPos::new(2, 64, 0), DigOptions::default().best_tool(false).face(Face::Up)).await?;
Source

pub async fn place(&self, against: BlockPos, face: Face) -> Result<(), Error>

Places the held block against against’s face (the new block goes to face.offset(against)): turns until the server has the crosshair on that face, sends the right click at the crosshair’s hit point, and waits until the block appears.

Fails with Error::NoSupport (air), Error::Occupied (the target is not air / liquid, or the player stands in it), Error::WouldActivate (a chest, door, … : the click would use it), Error::NothingHeld, Error::OutOfReach, Error::NotPlaced (the server refused) and the usual interrupts.

use ghast_client::{BlockPos, Face};
bot.equip("cobblestone").await?;
bot.place(BlockPos::new(2, 63, 0), Face::Up).await?; // on top of the block at y 63
Source

pub async fn activate_block(&self, pos: BlockPos) -> Result<(), Error>

Right-clicks pos (opens a chest, flips a lever, uses a door, …): turns until the server has the crosshair on the block, then sends the click. Returns once it was sent; see Bot::open_container to wait for a window.

use ghast_client::BlockPos;
bot.activate_block(BlockPos::new(5, 64, 5)).await?; // a lever
Source

pub async fn consume(&self) -> Result<(), Error>

Uses the held item until it is done: eats / drinks (food needs a non-full food bar; golden apples always), with the right button held until the server ends the use. Fails with Error::CannotUse when the use does not start. Look away from containers / doors first (the right click would use them; checked: Error::WouldActivate).

if bot.health().food < 18 {
    bot.equip("bread").await?;
    bot.consume().await?;
}
Source

pub fn activate_item(&self)

Starts using the held item (right button held: draw a bow, block with a sword / shield, start eating). Release it with Bot::deactivate_item.

bot.equip("bow").await?;
bot.activate_item();
bot.wait_ticks(20).await; // full draw
bot.deactivate_item();      // shoot
Source

pub fn deactivate_item(&self)

Releases the mouse buttons (ends an item use, stops digging).

bot.deactivate_item();
Source

pub fn swing(&self)

Swings the arm.

bot.swing();
Source

pub async fn attack(&self, id: i32) -> Result<(), Error>

Attacks entity id: turns until the server’s crosshair is on it, then attacks (refused by the client unless it is). Needs ghast_client::Interests::ENTITIES.

if let Some(z) = bot.nearest_entity(|e| e.name == "zombie", 4.0).await? {
    bot.attack(z.id).await?;
}
Source§

impl Bot

Source

pub fn events(&self) -> Events

Subscribes to the bot’s events from the next tick on (buffered until read).

use ghast_ext::Event;
let mut events = bot.events();
while let Some(ev) = events.recv().await {
    match ev {
        Event::Chat(m) => println!("chat: {}", m.plain()),
        Event::Died => bot.respawn(),
        _ => {}
    }
}
Source

pub async fn wait_for<F>(&self, pred: F) -> Result<Event, Error>
where F: FnMut(&Event) -> bool + Send,

Waits for the first event (from the next tick on) that matches pred and returns it. Fails with Error::Disconnected when the session ends first.

use ghast_ext::Event;
bot.wait_for(|ev| matches!(ev, Event::Chat(m) if m.plain().contains("hi"))).await?;
bot.chat("hello");
Source

pub fn chat(&self, text: impl Into<String>)

Sends a chat line or a command (/...) in this tick (truncated to the version’s limit like vanilla).

bot.chat("hello");
bot.chat("/spawn");
Source

pub async fn wait_for_chat<F>(&self, pred: F) -> Result<ChatMessage, Error>
where F: FnMut(&ChatMessage) -> bool + Send,

Waits for a chat message (from the next tick on) that matches pred.

let m = bot.wait_for_chat(|m| m.plain().starts_with("<Steve>")).await?;
println!("{}", m.plain());
Source

pub async fn command<F>( &self, text: impl Into<String>, pred: F, ticks: u64, ) -> Result<ChatMessage, Error>
where F: FnMut(&ChatMessage) -> bool + Send,

Sends text and waits up to ticks for the first chat reply that matches pred (subscribed before sending, so a fast reply is not missed).

let reply = bot
    .command("/balance", |m| m.plain().contains("Balance"), 100)
    .await?;
Source

pub fn respawn(&self)

Asks the server to respawn (only sent while dead).

if bot.is_dead() { bot.respawn(); }
Source

pub fn disconnect(&self, reason: impl Into<String>)

Ends the session after this tick’s packets (SessionEnd::Quit(reason)).

bot.disconnect("bye");
Source§

impl Bot

Source

pub fn tick(&self) -> u64

Ticks this behaviour ran in the current session (it does not advance while the server is silent and the behaviour is on hold).

let t = bot.tick();
bot.wait_ticks(20).await;
assert!(bot.tick() >= t + 20);
Source

pub fn version(&self) -> GameVersion

The protocol version of the session.

if bot.version() == ghast_client::GameVersion::V1_8_9 { /* ... */ }
Source

pub fn pose(&self) -> Pose

The client pose at the start of this tick.

let p = bot.pose().pos;
println!("at {:.1} {:.1} {:.1}", p.x, p.y, p.z);
Source

pub fn sent(&self) -> Pose

The pose the server has (the last movement packet): what it judges actions against.

let server_yaw = bot.sent().yaw;
Source

pub fn eyes(&self) -> Vec3

Eye position at the start of this tick.

let eyes = bot.eyes();
Source

pub fn health(&self) -> Health

Health, food and saturation.

if bot.health().food < 15 { /* eat */ }
Source

pub fn is_dead(&self) -> bool

The player is dead (see Bot::respawn).

if bot.is_dead() { bot.respawn(); }
Source

pub fn game_mode(&self) -> GameMode

Game mode.

let creative = bot.game_mode() == ghast_client::GameMode::Creative;
Source

pub fn held_slot(&self) -> u8

The selected hotbar slot (0 … 8).

let slot = bot.held_slot();
Source

pub fn open_window(&self) -> Option<i32>

Id of the open container window.

if bot.open_window().is_some() { /* a chest is open */ }
Source

pub fn entity_id(&self) -> i32

Our entity id.

let me = bot.entity_id();
Source

pub fn dimension(&self) -> String

The current dimension ("0" / "-1" / "1" on 1.8, the world name on 1.16).

let nether = bot.dimension() == "-1";
Source

pub fn with<R, F>(&self, f: F) -> With<R> ⓘ
where R: Send + 'static, F: FnOnce(&mut TickContext<'_>) -> R + Send + 'static,

Runs f with this tick’s TickContext and returns its result. From a task the Ext executor polls, f runs in the same tick (before the movement packet), so several with calls in a row cost no ticks. Actions inside f follow the usual rules (set_aim only for this tick, aim first and act on a later tick, …).

A panic in f resumes in the awaiting task. Fails with Error::Disconnected once the session ended.

let (stone, raw) = bot
    .with(|ctx| {
        let p = ghast_client::BlockPos::new(0, 63, 0);
        (ctx.world().raw_block(p.x, p.y, p.z), ctx.broken())
    })
    .await?;
Source

pub fn act<F>(&self, f: F)
where F: FnOnce(&mut TickContext<'_>) + Send + 'static,

Queues f for this tick (or the next one) without waiting for it: requests run in the order they were made. For fire-and-forget actions.

bot.act(|ctx| ctx.swing());
Source

pub fn wait_ticks(&self, n: u64) -> WaitTicks ⓘ

Waits n behaviour ticks (0 returns at once). Resolves at once when the session ended.

bot.wait_ticks(20).await; // one second
Source

pub fn next_tick(&self) -> WaitTicks ⓘ

Waits for the next tick.

loop {
    if bot.health().health < 10.0 { break; }
    bot.next_tick().await;
}
Source

pub fn sleep(&self, d: Duration) -> WaitTicks ⓘ

Waits about d of game time, in whole ticks (50 ms each, rounded up).

bot.sleep(std::time::Duration::from_secs(2)).await;
Source

pub fn timeout<F: Future>(&self, ticks: u64, fut: F) -> Timeout<F> ⓘ

Runs fut and gives up after ticks ticks with Error::Timeout (fut is dropped, which cancels it; helpers release their buttons when dropped).

let pos = ghast_client::BlockPos::new(3, 64, 0);
bot.timeout(200, bot.dig(pos)).await??;
Source

pub async fn wait_until<F>(&self, cond: F) -> Result<(), Error>
where F: Fn(&TickContext<'_>) -> bool + Send + Sync + 'static,

Waits until cond holds, checked once per tick with the tick’s context (also at once).

bot.wait_until(|ctx| ctx.pose().on_ground).await?;
Source

pub fn spawn<T, F>(&self, fut: F) -> JoinHandle<T> ⓘ
where T: Send + 'static, F: Future<Output = T> + Send + 'static,

Runs fut as another task of this bot (polled by the same executor, inside the ticks). It is cancelled when the session ends. The handle gives its result.

let b = bot.clone();
let guard = bot.spawn(async move {
    loop {
        if b.is_dead() { b.respawn(); }
        b.wait_ticks(20).await;
    }
});
// ... later
guard.abort();
Source

pub fn require(&self, interests: Interests)

Asks the helpers’ packet groups on top of the configured Ext::interests (e.g. Interests::ENTITIES for entity helpers). Better set up front with Ext::interests: a tracker started late misses entities that already exist.

bot.require(ghast_client::Interests::BLOCK_UPDATES);
Source§

impl Bot

Source

pub async fn block_at(&self, pos: BlockPos) -> Result<Option<Block>, Error>

The block at pos; None when its column is not loaded (never air by guess).

use ghast_client::BlockPos;
if let Some(b) = bot.block_at(BlockPos::new(0, 63, 0)).await? {
    println!("{}", b.name());
}
Source

pub async fn find_blocks( &self, what: impl Into<BlockMatch>, max_distance: f64, count: usize, ) -> Result<Vec<BlockPos>, Error>

Up to count blocks matching what within max_distance of the eyes, nearest first (loaded columns only). what is a name, an array of names or a predicate on Block. The search runs inside one tick: keep max_distance modest (32 blocks is ~270k positions; all-air sections are skipped).

let ores = bot.find_blocks(|b: ghast_ext::Block| b.is_ore(), 32.0, 10).await?;
let chests = bot.find_blocks("chest", 16.0, 1).await?;
let logs = bot.find_blocks(["log", "log2"], 24.0, 64).await?;
Source

pub async fn find_block( &self, what: impl Into<BlockMatch>, max_distance: f64, ) -> Result<Option<BlockPos>, Error>

The nearest block matching what within max_distance (see Bot::find_blocks).

if let Some(chest) = bot.find_block("chest", 16.0).await? { /* ... */ }
Source

pub async fn find_entities<F>( &self, pred: F, radius: f64, ) -> Result<Vec<EntityInfo>, Error>
where F: Fn(&EntityInfo) -> bool + Send + 'static,

Tracked entities (not the bot) within radius of the bot matching pred, nearest first. Needs ghast_client::Interests::ENTITIES (crate::Ext::interests); empty without it.

let zombies = bot.find_entities(|e| e.name == "zombie", 16.0).await?;
Source

pub async fn nearest_entity<F>( &self, pred: F, radius: f64, ) -> Result<Option<EntityInfo>, Error>
where F: Fn(&EntityInfo) -> bool + Send + 'static,

The nearest tracked entity within radius matching pred (see Bot::find_entities).

let player = bot.nearest_entity(|e| e.name == "player", 32.0).await?;
Source

pub async fn entity(&self, id: i32) -> Result<Option<EntityInfo>, Error>

A tracked entity by id.

if let Some(e) = bot.entity(id).await? { println!("{:?}", e.pos); }
Source

pub async fn player(&self, name: &str) -> Result<Option<EntityInfo>, Error>

The player entity with this tab-list name (needs ghast_client::Interests::ENTITIES and ghast_client::Interests::PLAYER_LIST).

if let Some(p) = bot.player("Steve").await? { println!("Steve at {:?}", p.pos); }
Source§

impl Bot

Source

pub async fn goto(&self, goal: Goal) -> Result<(), Error>

Walks to goal along a path planned by ghast_pathfinder with the default Config (sprinting, gap jumps, swimming, ladders; no digging or placing) and followed by its Follower: every plan is first run through the vanilla-exact physics, moves the simulation fails are planned around, and the follower replans when it gets stuck or leaves the path.

Fails with Error::NoPath when no path exists (or the start is not loaded), Error::Stuck after too many replans, and the usual interrupts (teleport / death, see crate::Ext::interrupt_on_teleport). Unloaded terrain is never treated as air: a goal beyond it is approached through partial paths. Dropping the future releases the keys.

A long plan is spread over several ticks (by default at most 2000 nodes and 5 ms of planning per tick, see FollowConfig::budget); the bot stands still meanwhile and the client keeps sending its movement packet every tick.

use ghast_ext::pathfinder::Goal;
bot.goto(Goal::Block([20, 64, -5])).await?;
bot.goto(Goal::Near { pos: [0, 64, 0], radius: 3.0 }).await?;
Source

pub async fn goto_with( &self, follower: Follower, goal: Goal, ) -> Result<(), Error>

Bot::goto with a configured Follower (planner options such as digging or placing, controller options, replan budget).

use ghast_ext::pathfinder::{Config, DigCost, FollowConfig, Follower, Goal, Pathfinder};
let pf = Pathfinder::new(Config::default().with_dig(Some(DigCost::default())));
let follower = Follower::new(pf, FollowConfig::default());
bot.goto_with(follower, Goal::Xz { x: 100, z: 40 }).await?;
Source

pub async fn follow_path(&self, id: i32, range: f64) -> Result<(), Error>

Follows entity id along planned paths (the planner and follower of Bot::goto), staying within range blocks of it: through mazes, over gaps, around walls (unlike Bot::follow, which walks in a straight line). The bot plans again when the entity has moved more than range (at least 2) blocks from where the current path goes, at most one plan at a time; within range it stands and looks at the entity. When the entity is out of reach (flying, across a gap too wide), the bot walks to the reachable block closest to it and waits there until the entity moves.

Runs until the entity is gone (Error::NoSuchEntity) or the task is cancelled (e.g. with Bot::timeout or crate::JoinHandle::abort). Needs ghast_client::Interests::ENTITIES. Dropping the future releases the keys.

if let Some(p) = bot.player("Steve").await? {
    let _ = bot.timeout(20 * 60, bot.follow_path(p.id, 2.0)).await; // one minute
}
Source

pub async fn follow_path_with( &self, follower: Follower, id: i32, range: f64, ) -> Result<(), Error>

Bot::follow_path with a configured Follower.

Source§

impl Bot

Source

pub async fn count(&self, item: impl Into<ItemMatch>) -> Result<i32, Error>

The window-0 slots / counts are read in the tick: total count of matching items in the player inventory (hotbar, main, armour, off hand).

let n = bot.count("cobblestone").await?;
Source

pub async fn find_item( &self, item: impl Into<ItemMatch>, ) -> Result<Option<(usize, Stack)>, Error>

The PlayerInventory index (0–8 hotbar, 9–35 main) of the first matching stack, hotbar first, and a copy of the stack.

if let Some((index, stack)) = bot.find_item("bread").await? {
    println!("{} bread in slot {index}", stack.count());
}
Source

pub async fn held_item(&self) -> Result<Option<Stack>, Error>

The held stack (a copy).

let held = bot.held_item().await?;
Source

pub fn select_slot(&self, slot: u8)

Selects hotbar slot slot (0 … 8) in this tick.

bot.select_slot(2);
Source

pub async fn equip(&self, item: impl Into<ItemMatch>) -> Result<u8, Error>

Holds a matching item: selects it when it is in the hotbar; otherwise swaps it from the main inventory into the hotbar (an empty hotbar slot, else the held one) with a number-key click in the inventory screen (opened and closed again unless a container is open), then selects it. Returns the hotbar slot.

bot.equip("diamond_pickaxe").await?;
bot.equip(|s: &ghast_client::inventory::Stack| s.id() == 278).await?;
Source

pub async fn equip_for_block(&self, pos: BlockPos) -> Result<u8, Error>

Selects the hotbar tool that digs pos fastest, first bringing a faster one from the main inventory into the hotbar if there is one. Returns the hotbar slot.

use ghast_client::BlockPos;
let p = BlockPos::new(1, 60, 1);
bot.equip_for_block(p).await?;
bot.dig(p).await?;
Source

pub async fn swap_to_hotbar( &self, index: usize, hotbar: u8, ) -> Result<(), Error>

Swaps PlayerInventory index index with hotbar slot hotbar (number-key click). Uses the open container if there is one, else opens the inventory screen for it and closes it again.

bot.swap_to_hotbar(20, 0).await?; // main slot 20 <-> hotbar 0
Source

pub async fn drop_slot(&self, index: usize, all: bool) -> Result<(), Error>

Drops the stack at PlayerInventory index index (all of it, or one with all = false), with a Q click in the inventory screen.

bot.drop_slot(9, true).await?;
Source

pub async fn toss(&self, item: impl Into<ItemMatch>) -> Result<i32, Error>

Drops every matching stack from the hotbar and main inventory; returns how many items were dropped.

let n = bot.toss("rotten_flesh").await?;
Source

pub async fn click(&self, click: Click) -> Result<(), Error>

Sends a window click in the open screen and waits for the server’s confirm. Retries (one tick at a time) while the click must wait: the look is turning (clicks only while still), another click is in flight, or the same-tick packet rules forbid it. Fails with Error::Click for refusals that will not go away (no screen, invalid slot, unpredictable result), Error::ClickRejected or Error::ClickTimedOut.

use ghast_client::inventory::Click;
bot.click(Click::QuickMove { slot: 0, right: false }).await?; // shift-click slot 0
Source

pub async fn close_window(&self) -> Result<(), Error>

Closes the open GUI (container or inventory screen).

bot.close_window().await?;
Source

pub async fn open_container(&self, pos: BlockPos) -> Result<Container, Error>

Right-clicks the container at pos (chest, furnace, …) and waits for its window.

if let Some(pos) = bot.find_block("chest", 5.0).await? {
    let chest = bot.open_container(pos).await?;
    bot.deposit("cobblestone", None).await?;
    bot.close_window().await?;
}
Source

pub async fn container_items(&self) -> Result<Vec<(usize, Stack)>, Error>

The open container’s slots (index, stack copy), container part only.

for (slot, stack) in bot.container_items().await? {
    println!("{slot}: {} x{}", stack.id(), stack.count());
}
Source

pub async fn deposit( &self, item: impl Into<ItemMatch>, max: Option<i32>, ) -> Result<i32, Error>

Shift-clicks matching stacks from the player part of the open container into it, whole stacks, until at least max items moved (None: all). Returns how many items left the player inventory (it stops when the container is full).

let moved = bot.deposit("cobblestone", Some(128)).await?;
Source

pub async fn withdraw( &self, item: impl Into<ItemMatch>, max: Option<i32>, ) -> Result<i32, Error>

Shift-clicks matching stacks from the open container into the player inventory, whole stacks, until at least max items moved (None: all). Returns how many items arrived.

let got = bot.withdraw("bread", Some(16)).await?;
Source§

impl Bot

Source

pub async fn look_at(&self, point: Vec3) -> Result<(), Error>

Turns to look at point in whole mouse counts (sensitivity GCD, at most 14° yaw / 10.5° pitch per tick, like a player’s mouse) and returns once the server has the final look. The eyes are re-read every tick, so it also works while moving.

use ghast_client::Vec3;
bot.look_at(Vec3::new(10.5, 65.0, -3.5)).await?;
Source

pub async fn look(&self, yaw: f32, pitch: f32) -> Result<(), Error>

Turns to an absolute yaw / pitch (degrees; pitch clamped to ±89.5 like the client) and returns once the server has the final look.

bot.look(90.0, 0.0).await?; // face -X
Source

pub async fn look_at_block( &self, pos: BlockPos, face: Option<Face>, ) -> Result<BlockHit, Error>

Turns until the crosshair (as the server judges it, from the sent pose) is on pos (on face, if given) and returns the hit. Fails with Error::OutOfReach when no visible point of the block is within reach (4.5).

use ghast_client::BlockPos;
let hit = bot.look_at_block(BlockPos::new(2, 63, 0), None).await?;
println!("on face {:?} at {:?}", hit.face, hit.hit);
Source§

impl Bot

Source

pub async fn walk_straight_to( &self, goal: Vec3, range: f64, ) -> Result<(), Error>

Walks in a straight line until within range blocks (horizontally) of goal: turns toward it (whole mouse counts), holds forward (sprinting while more than 3 blocks away), and jumps when blocked. No path planning: for open ground. Fails with Error::Stuck after 3 s without progress, or when teleported / dead.

use ghast_client::Vec3;
bot.walk_straight_to(Vec3::new(10.5, 64.0, 3.5), 0.5).await?;
Source

pub async fn follow(&self, id: i32, range: f64) -> Result<(), Error>

Follows entity id, staying within range blocks of it, with the straight walker (see Bot::walk_straight_to): for open ground. To follow through mazes, over gaps and around walls use Bot::follow_path (feature pathfinder). Runs until the entity is gone (Error::NoSuchEntity), the walker is stuck, or the task is cancelled (e.g. with Bot::timeout or crate::JoinHandle::abort). Needs ghast_client::Interests::ENTITIES.

if let Some(p) = bot.player("Steve").await? {
    let _ = bot.timeout(20 * 60, bot.follow(p.id, 2.0)).await; // one minute
}
Source

pub fn set_controls(&self, controls: Controls)

Sets the movement keys (kept until changed) in this tick.

use ghast_client::Controls;
bot.set_controls(Controls { forward: true, jump: true, ..Controls::NONE });
bot.wait_ticks(10).await;
bot.set_controls(Controls::NONE);

Trait Implementations§

Source§

impl Clone for Bot

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Bot

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Forget for Bot

§

impl Freeze for Bot

§

impl Move for Bot

§

impl RefUnwindSafe for Bot

§

impl Send for Bot

§

impl Sync for Bot

§

impl Unpin for Bot

§

impl UnsafeUnpin for Bot

§

impl UnwindSafe for Bot

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V