Movatterモバイル変換


[0]ホーム

URL:


column

std

Macrocolumn 

1.38.0 ·Source
macro_rules! column {    () => { ... };}
Expand description

Expands to the column number at which it was invoked.

Withline! andfile!, these macros provide debugging information fordevelopers about the location within the source.

The expanded expression has typeu32 and is 1-based, so the first columnin each line evaluates to 1, the second to 2, etc. This is consistentwith error messages by common compilers or popular editors.The returned column isnot necessarily the line of thecolumn! invocation itself,but rather the first macro invocation leading up to the invocationof thecolumn! macro.

§Examples

letcurrent_col =column!();println!("defined on column: {current_col}");

column! counts Unicode code points, not bytes or graphemes. As a result, the first twoinvocations return the same value, but the third does not.

leta = ("foobar",column!()).1;letb = ("人之初性本善",column!()).1;letc = ("f̅o̅o̅b̅a̅r̅",column!()).1;// Uses combining overline (U+0305)assert_eq!(a, b);assert_ne!(b, c);

[8]ページ先頭

©2009-2026 Movatter.jp