You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/advanced/forward_refs.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,9 +16,9 @@ class Node(struct):
16
16
17
17
At inflation time, the string `"Node"` is resolved to the actual `Node` class. This works because Python's `from __future__ import annotations` (used internally by libdestruct) defers annotation evaluation.
18
18
19
-
## The `ptr_to_self` Shortcut
19
+
## The Legacy `ptr_to_self` Shortcut
20
20
21
-
For the common case of a pointer to the enclosing struct, use `ptr_to_self`:
21
+
For the common case of a pointer to the enclosing struct, the legacy `ptr_to_self` syntax is also available:
22
22
23
23
```python
24
24
from libdestruct import struct, c_int, ptr_to_self
@@ -28,7 +28,7 @@ class Node(struct):
28
28
next: ptr_to_self
29
29
```
30
30
31
-
This is equivalent to `ptr["Node"]` but doesn't require you to spell out the type name.
31
+
This is equivalent to `ptr["Node"]` but doesn't require you to spell out the type name. The `ptr["TypeName"]` syntax is preferred as it is more explicit.
0 commit comments