# session.Session.next_window

- **Module:** session.Session
- **Package:** libtmux
- **Language:** Rust
- **Kind:** method
- **Source:** https://github.com/libtmux/libtmux-rs/blob/8a648c0894dfffc9303583f753b6c8ae01f2fe76/crates/libtmux/src/session.rs#L379
- **Page:** https://libtmux.org/reference/rs/session-session-next_window/

```
session.Session.next_window(self) -> Result<Option<Window>, Error>
```

Move to the next window, and return it.

`None` when there is no next window, which a session holding one
window never has. That is an ordinary state rather than a failure, so
it is reported as absence; an error means tmux could not be reached or
refused the move for some other reason.

# Errors

Returns an error when tmux cannot be reached or refuses the move.

## Example

```rust
let guard = libtmux::test::TestServer::new().await?;
let session = guard.server().new_session("moving").await?;

// One window, so there is nowhere to go and nothing broke.
assert!(session.next_window().await?.is_none());

session.new_window("second").await?;
assert!(session.next_window().await?.is_some());

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