# pane.Pane.join_into

- **Module:** pane.Pane
- **Package:** libtmux
- **Language:** Rust
- **Kind:** method
- **Source:** https://github.com/libtmux/libtmux-rs/blob/8a648c0894dfffc9303583f753b6c8ae01f2fe76/crates/libtmux/src/pane.rs#L1030
- **Page:** https://libtmux.org/reference/rs/pane-pane-join_into/

```
pane.Pane.join_into(self, beside: &Self, options: crate::JoinOptions) -> Result<Self, Error>
```

Move this pane into another window, beside a pane already there.

The inverse of [`Pane::break_out`], and it consumes the handle for the
same reason: the pane's window changes, so a snapshot of where it used
to be is wrong. The pane keeps its id and everything running in it, so
the handle returned is this same pane read again where it now lives.

# Errors

Returns [`Error::ServerMismatch`] when `beside` belongs to another
server, or an error when tmux refuses the move, including a pane joined
to its own window.

## Example

```rust
use libtmux::{JoinOptions, SplitDirection};

let guard = libtmux::test::TestServer::new().await?;
let session = guard.server().new_session("moving").await?;
let window = session.active_window().await?.expect("a window");
let elsewhere = session.new_window("elsewhere").await?;

let stranded = elsewhere.panes().await?.remove(0);
let here = window.panes().await?.remove(0);
let moved = stranded
    .join_into(&here, JoinOptions::new(SplitDirection::Below))
    .await?;

assert_eq!(moved.window_id(), window.id());

guard.shutdown().await?;
```
