-
Notifications
You must be signed in to change notification settings - Fork 120
/
Copy pathstruct.PyReadonlyArray.html
786 lines (723 loc) · 152 KB
/
struct.PyReadonlyArray.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Read-only borrow of an array."><title>PyReadonlyArray in numpy::borrow - Rust</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../static.files/rustdoc-ac92e1bbe349e143.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="numpy" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0 (07dca489a 2024-02-04)" data-channel="1.76.0" data-search-js="search-2b6ce74ff89ae146.js" data-settings-js="settings-4313503d2e1961c2.js" ><script src="../../static.files/storage-f2adc0d6ca4d09fb.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-305769736d49e732.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-feafe1bb7466e4bd.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-16x16-8b506e7a72182f1c.png"><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-422f7d1d52889060.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-2c020d218678b618.svg"></head><body class="rustdoc struct"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle">☰</button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../numpy/index.html">numpy</a><span class="version">0.20.0</span></h2></div><h2 class="location"><a href="#">PyReadonlyArray</a></h2><div class="sidebar-elems"><section><h3><a href="#implementations">Methods</a></h3><ul class="block method"><li><a href="#method.as_array">as_array</a></li><li><a href="#method.as_matrix">as_matrix</a></li><li><a href="#method.as_matrix-1">as_matrix</a></li><li><a href="#method.as_slice">as_slice</a></li><li><a href="#method.get">get</a></li><li><a href="#method.try_as_matrix">try_as_matrix</a></li></ul><h3><a href="#deref-methods-PyArray%3CT,+D%3E">Methods from Deref<Target=PyArray<T, D>></a></h3><ul class="block deref-methods"><li><a href="#method.as_array-1">as_array</a></li><li><a href="#method.as_array_mut">as_array_mut</a></li><li><a href="#method.as_raw_array">as_raw_array</a></li><li><a href="#method.as_raw_array_mut">as_raw_array_mut</a></li><li><a href="#method.as_slice-1">as_slice</a></li><li><a href="#method.as_slice_mut">as_slice_mut</a></li><li><a href="#method.as_untyped">as_untyped</a></li><li><a href="#method.cast">cast</a></li><li><a href="#method.copy_to">copy_to</a></li><li><a href="#method.data">data</a></li><li><a href="#method.dims">dims</a></li><li><a href="#method.get-1">get</a></li><li><a href="#method.get_mut">get_mut</a></li><li><a href="#method.get_owned">get_owned</a></li><li><a href="#method.item">item</a></li><li><a href="#method.readonly">readonly</a></li><li><a href="#method.readwrite">readwrite</a></li><li><a href="#method.reshape">reshape</a></li><li><a href="#method.reshape_with_order">reshape_with_order</a></li><li><a href="#method.resize">resize</a></li><li><a href="#method.to_dyn">to_dyn</a></li><li><a href="#method.to_owned">to_owned</a></li><li><a href="#method.to_owned_array">to_owned_array</a></li><li><a href="#method.to_vec">to_vec</a></li><li><a href="#method.try_as_matrix-1">try_as_matrix</a></li><li><a href="#method.try_as_matrix_mut">try_as_matrix_mut</a></li><li><a href="#method.try_readonly">try_readonly</a></li><li><a href="#method.try_readwrite">try_readwrite</a></li><li><a href="#method.uget">uget</a></li><li><a href="#method.uget_mut">uget_mut</a></li><li><a href="#method.uget_raw">uget_raw</a></li></ul><h3><a href="#deref-methods-PyUntypedArray">Methods from Deref<Target=PyUntypedArray></a></h3><ul class="block deref-methods"><li><a href="#method.as_array_ptr">as_array_ptr</a></li><li><a href="#method.dtype">dtype</a></li><li><a href="#method.is_c_contiguous">is_c_contiguous</a></li><li><a href="#method.is_contiguous">is_contiguous</a></li><li><a href="#method.is_empty">is_empty</a></li><li><a href="#method.is_fortran_contiguous">is_fortran_contiguous</a></li><li><a href="#method.len">len</a></li><li><a href="#method.ndim">ndim</a></li><li><a href="#method.shape">shape</a></li><li><a href="#method.strides">strides</a></li></ul><h3><a href="#deref-methods-PyAny">Methods from Deref<Target=PyAny></a></h3><ul class="block deref-methods"><li><a href="#method.as_ptr">as_ptr</a></li><li><a href="#method.call">call</a></li><li><a href="#method.call0">call0</a></li><li><a href="#method.call1">call1</a></li><li><a href="#method.call_method">call_method</a></li><li><a href="#method.call_method0">call_method0</a></li><li><a href="#method.call_method1">call_method1</a></li><li><a href="#method.compare">compare</a></li><li><a href="#method.contains">contains</a></li><li><a href="#method.del_item">del_item</a></li><li><a href="#method.delattr">delattr</a></li><li><a href="#method.dir">dir</a></li><li><a href="#method.downcast">downcast</a></li><li><a href="#method.downcast_exact">downcast_exact</a></li><li><a href="#method.downcast_unchecked">downcast_unchecked</a></li><li><a href="#method.eq">eq</a></li><li><a href="#method.extract">extract</a></li><li><a href="#method.ge">ge</a></li><li><a href="#method.get_item">get_item</a></li><li><a href="#method.get_refcnt">get_refcnt</a></li><li><a href="#method.get_type">get_type</a></li><li><a href="#method.get_type_ptr">get_type_ptr</a></li><li><a href="#method.getattr">getattr</a></li><li><a href="#method.gt">gt</a></li><li><a href="#method.hasattr">hasattr</a></li><li><a href="#method.hash">hash</a></li><li><a href="#method.into_ptr">into_ptr</a></li><li><a href="#method.is">is</a></li><li><a href="#method.is_callable">is_callable</a></li><li><a href="#method.is_ellipsis">is_ellipsis</a></li><li><a href="#method.is_empty-1">is_empty</a></li><li><a href="#method.is_exact_instance">is_exact_instance</a></li><li><a href="#method.is_exact_instance_of">is_exact_instance_of</a></li><li><a href="#method.is_instance">is_instance</a></li><li><a href="#method.is_instance_of">is_instance_of</a></li><li><a href="#method.is_none">is_none</a></li><li><a href="#method.is_true">is_true</a></li><li><a href="#method.is_truthy">is_truthy</a></li><li><a href="#method.iter">iter</a></li><li><a href="#method.le">le</a></li><li><a href="#method.len-1">len</a></li><li><a href="#method.lt">lt</a></li><li><a href="#method.ne">ne</a></li><li><a href="#method.py">py</a></li><li><a href="#method.py_super">py_super</a></li><li><a href="#method.repr">repr</a></li><li><a href="#method.rich_compare">rich_compare</a></li><li><a href="#method.set_item">set_item</a></li><li><a href="#method.setattr">setattr</a></li><li><a href="#method.str">str</a></li></ul><h3><a href="#trait-implementations">Trait Implementations</a></h3><ul class="block trait-implementation"><li><a href="#impl-Clone-for-PyReadonlyArray%3C'a,+T,+D%3E">Clone</a></li><li><a href="#impl-Debug-for-PyReadonlyArray%3C'py,+T,+D%3E">Debug</a></li><li><a href="#impl-Deref-for-PyReadonlyArray%3C'py,+T,+D%3E">Deref</a></li><li><a href="#impl-Drop-for-PyReadonlyArray%3C'a,+T,+D%3E">Drop</a></li><li><a href="#impl-FromPyObject%3C'py%3E-for-PyReadonlyArray%3C'py,+T,+D%3E">FromPyObject<'py></a></li></ul><h3><a href="#synthetic-implementations">Auto Trait Implementations</a></h3><ul class="block synthetic-implementation"><li><a href="#impl-RefUnwindSafe-for-PyReadonlyArray%3C'py,+T,+D%3E">!RefUnwindSafe</a></li><li><a href="#impl-Send-for-PyReadonlyArray%3C'py,+T,+D%3E">!Send</a></li><li><a href="#impl-Sync-for-PyReadonlyArray%3C'py,+T,+D%3E">!Sync</a></li><li><a href="#impl-UnwindSafe-for-PyReadonlyArray%3C'py,+T,+D%3E">!UnwindSafe</a></li><li><a href="#impl-Unpin-for-PyReadonlyArray%3C'py,+T,+D%3E">Unpin</a></li></ul><h3><a href="#blanket-implementations">Blanket Implementations</a></h3><ul class="block blanket-implementation"><li><a href="#impl-Any-for-T">Any</a></li><li><a href="#impl-Borrow%3CT%3E-for-T">Borrow<T></a></li><li><a href="#impl-BorrowMut%3CT%3E-for-T">BorrowMut<T></a></li><li><a href="#impl-From%3CT%3E-for-T">From<T></a></li><li><a href="#impl-FromPyObjectBound%3C'_,+'py%3E-for-T">FromPyObjectBound<'_, 'py></a></li><li><a href="#impl-Into%3CU%3E-for-T">Into<U></a></li><li><a href="#impl-Same-for-T">Same</a></li><li><a href="#impl-SupersetOf%3CSS%3E-for-SP">SupersetOf<SS></a></li><li><a href="#impl-ToOwned-for-T">ToOwned</a></li><li><a href="#impl-TryFrom%3CU%3E-for-T">TryFrom<U></a></li><li><a href="#impl-TryInto%3CU%3E-for-T">TryInto<U></a></li></ul></section><h2><a href="index.html">In numpy::borrow</a></h2></div></nav><div class="sidebar-resizer"></div>
<main><div class="width-limiter"><nav class="sub"><form class="search-form"><span></span><div id="sidebar-button" tabindex="-1"><a href="../../numpy/all.html" title="show sidebar"></a></div><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"><div id="help-button" tabindex="-1"><a href="../../help.html" title="help">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="main-heading"><h1>Struct <a href="../index.html">numpy</a>::<wbr><a href="index.html">borrow</a>::<wbr><a class="struct" href="#">PyReadonlyArray</a><button id="copy-path" title="Copy item path to clipboard"><img src="../../static.files/clipboard-7571035ce49a181d.svg" width="19" height="18" alt="Copy item path"></button></h1><span class="out-of-band"><a class="src" href="../../src/numpy/borrow/mod.rs.html#188-194">source</a> · <button id="toggle-all-docs" title="collapse all docs">[<span>−</span>]</button></span></div><pre class="rust item-decl"><code>pub struct PyReadonlyArray<'py, T, D><div class="where">where
T: <a class="trait" href="../trait.Element.html" title="trait numpy::Element">Element</a>,
D: <a class="trait" href="https://docs.rs/ndarray/0.15/ndarray/dimension/dimension_trait/trait.Dimension.html" title="trait ndarray::dimension::dimension_trait::Dimension">Dimension</a>,</div>{ <span class="comment">/* private fields */</span> }</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Read-only borrow of an array.</p>
<p>An instance of this type ensures that there are no instances of <a href="struct.PyReadwriteArray.html" title="struct numpy::borrow::PyReadwriteArray"><code>PyReadwriteArray</code></a>,
i.e. that only shared references into the interior of the array can be created safely.</p>
<p>See the <a href="index.html" title="mod numpy::borrow">module-level documentation</a> for more.</p>
</div></details><h2 id="implementations" class="section-header">Implementations<a href="#implementations" class="anchor">§</a></h2><div id="implementations-list"><details class="toggle implementors-toggle" open><summary><section id="impl-PyReadonlyArray%3C'py,+T,+D%3E" class="impl"><a class="src rightside" href="../../src/numpy/borrow/mod.rs.html#239-272">source</a><a href="#impl-PyReadonlyArray%3C'py,+T,+D%3E" class="anchor">§</a><h3 class="code-header">impl<'py, T, D> <a class="struct" href="struct.PyReadonlyArray.html" title="struct numpy::borrow::PyReadonlyArray">PyReadonlyArray</a><'py, T, D><div class="where">where
T: <a class="trait" href="../trait.Element.html" title="trait numpy::Element">Element</a>,
D: <a class="trait" href="https://docs.rs/ndarray/0.15/ndarray/dimension/dimension_trait/trait.Dimension.html" title="trait ndarray::dimension::dimension_trait::Dimension">Dimension</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.as_array" class="method"><a class="src rightside" href="../../src/numpy/borrow/mod.rs.html#252-255">source</a><h4 class="code-header">pub fn <a href="#method.as_array" class="fn">as_array</a>(&self) -> <a class="type" href="https://docs.rs/ndarray/0.15/ndarray/type.ArrayView.html" title="type ndarray::ArrayView">ArrayView</a><'_, T, D></h4></section></summary><div class="docblock"><p>Provides an immutable array view of the interior of the NumPy array.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.as_slice" class="method"><a class="src rightside" href="../../src/numpy/borrow/mod.rs.html#259-262">source</a><h4 class="code-header">pub fn <a href="#method.as_slice" class="fn">as_slice</a>(&self) -> <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><&<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.slice.html">[T]</a>, <a class="struct" href="../struct.NotContiguousError.html" title="struct numpy::NotContiguousError">NotContiguousError</a>></h4></section></summary><div class="docblock"><p>Provide an immutable slice view of the interior of the NumPy array if it is contiguous.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.get" class="method"><a class="src rightside" href="../../src/numpy/borrow/mod.rs.html#266-271">source</a><h4 class="code-header">pub fn <a href="#method.get" class="fn">get</a><I>(&self, index: I) -> <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.reference.html">&T</a>><div class="where">where
I: <a class="trait" href="../convert/trait.NpyIndex.html" title="trait numpy::convert::NpyIndex">NpyIndex</a><Dim = D>,</div></h4></section></summary><div class="docblock"><p>Provide an immutable reference to an element of the NumPy array if the index is within bounds.</p>
</div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-PyReadonlyArray%3C'py,+N,+D%3E" class="impl"><a class="src rightside" href="../../src/numpy/borrow/mod.rs.html#275-293">source</a><a href="#impl-PyReadonlyArray%3C'py,+N,+D%3E" class="anchor">§</a><h3 class="code-header">impl<'py, N, D> <a class="struct" href="struct.PyReadonlyArray.html" title="struct numpy::borrow::PyReadonlyArray">PyReadonlyArray</a><'py, N, D><div class="where">where
N: <a class="trait" href="https://docs.rs/nalgebra/0.25.0/nalgebra/base/scalar/trait.Scalar.html" title="trait nalgebra::base::scalar::Scalar">Scalar</a> + <a class="trait" href="../trait.Element.html" title="trait numpy::Element">Element</a>,
D: <a class="trait" href="https://docs.rs/ndarray/0.15/ndarray/dimension/dimension_trait/trait.Dimension.html" title="trait ndarray::dimension::dimension_trait::Dimension">Dimension</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.try_as_matrix" class="method"><a class="src rightside" href="../../src/numpy/borrow/mod.rs.html#282-292">source</a><h4 class="code-header">pub fn <a href="#method.try_as_matrix" class="fn">try_as_matrix</a><R, C, RStride, CStride>(
&self
) -> <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="type" href="https://docs.rs/nalgebra/0.25.0/nalgebra/base/matrix_view/type.MatrixView.html" title="type nalgebra::base::matrix_view::MatrixView">MatrixView</a><'_, N, R, C, RStride, CStride>><div class="where">where
R: <a class="trait" href="https://docs.rs/nalgebra/0.25.0/nalgebra/base/dimension/trait.Dim.html" title="trait nalgebra::base::dimension::Dim">Dim</a>,
C: <a class="trait" href="https://docs.rs/nalgebra/0.25.0/nalgebra/base/dimension/trait.Dim.html" title="trait nalgebra::base::dimension::Dim">Dim</a>,
RStride: <a class="trait" href="https://docs.rs/nalgebra/0.25.0/nalgebra/base/dimension/trait.Dim.html" title="trait nalgebra::base::dimension::Dim">Dim</a>,
CStride: <a class="trait" href="https://docs.rs/nalgebra/0.25.0/nalgebra/base/dimension/trait.Dim.html" title="trait nalgebra::base::dimension::Dim">Dim</a>,</div></h4></section></summary><div class="docblock"><p>Try to convert this array into a <a href="https://docs.rs/nalgebra/0.25.0/nalgebra/base/matrix_view/type.MatrixView.html" title="type nalgebra::base::matrix_view::MatrixView"><code>nalgebra::MatrixView</code></a> using the given shape and strides.</p>
</div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-PyReadonlyArray%3C'py,+N,+Dim%3C%5Busize;+1%5D%3E%3E" class="impl"><a class="src rightside" href="../../src/numpy/borrow/mod.rs.html#296-309">source</a><a href="#impl-PyReadonlyArray%3C'py,+N,+Dim%3C%5Busize;+1%5D%3E%3E" class="anchor">§</a><h3 class="code-header">impl<'py, N> <a class="struct" href="struct.PyReadonlyArray.html" title="struct numpy::borrow::PyReadonlyArray">PyReadonlyArray</a><'py, N, <a class="type" href="../type.Ix1.html" title="type numpy::Ix1">Ix1</a>><div class="where">where
N: <a class="trait" href="https://docs.rs/nalgebra/0.25.0/nalgebra/base/scalar/trait.Scalar.html" title="trait nalgebra::base::scalar::Scalar">Scalar</a> + <a class="trait" href="../trait.Element.html" title="trait numpy::Element">Element</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.as_matrix" class="method"><a class="src rightside" href="../../src/numpy/borrow/mod.rs.html#306-308">source</a><h4 class="code-header">pub fn <a href="#method.as_matrix" class="fn">as_matrix</a>(&self) -> <a class="type" href="https://docs.rs/nalgebra/0.25.0/nalgebra/base/alias_view/type.DMatrixView.html" title="type nalgebra::base::alias_view::DMatrixView">DMatrixView</a><'_, N, <a class="struct" href="https://docs.rs/nalgebra/0.25.0/nalgebra/base/dimension/struct.Dyn.html" title="struct nalgebra::base::dimension::Dyn">Dyn</a>, <a class="struct" href="https://docs.rs/nalgebra/0.25.0/nalgebra/base/dimension/struct.Dyn.html" title="struct nalgebra::base::dimension::Dyn">Dyn</a>></h4></section></summary><div class="docblock"><p>Convert this one-dimensional array into a <a href="https://docs.rs/nalgebra/0.25.0/nalgebra/base/alias_view/type.DMatrixView.html" title="type nalgebra::base::alias_view::DMatrixView"><code>nalgebra::DMatrixView</code></a> using dynamic strides.</p>
<h5 id="panics"><a href="#panics">Panics</a></h5>
<p>Panics if the array has negative strides.</p>
</div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-PyReadonlyArray%3C'py,+N,+Dim%3C%5Busize;+2%5D%3E%3E" class="impl"><a class="src rightside" href="../../src/numpy/borrow/mod.rs.html#312-325">source</a><a href="#impl-PyReadonlyArray%3C'py,+N,+Dim%3C%5Busize;+2%5D%3E%3E" class="anchor">§</a><h3 class="code-header">impl<'py, N> <a class="struct" href="struct.PyReadonlyArray.html" title="struct numpy::borrow::PyReadonlyArray">PyReadonlyArray</a><'py, N, <a class="type" href="../type.Ix2.html" title="type numpy::Ix2">Ix2</a>><div class="where">where
N: <a class="trait" href="https://docs.rs/nalgebra/0.25.0/nalgebra/base/scalar/trait.Scalar.html" title="trait nalgebra::base::scalar::Scalar">Scalar</a> + <a class="trait" href="../trait.Element.html" title="trait numpy::Element">Element</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.as_matrix-1" class="method"><a class="src rightside" href="../../src/numpy/borrow/mod.rs.html#322-324">source</a><h4 class="code-header">pub fn <a href="#method.as_matrix-1" class="fn">as_matrix</a>(&self) -> <a class="type" href="https://docs.rs/nalgebra/0.25.0/nalgebra/base/alias_view/type.DMatrixView.html" title="type nalgebra::base::alias_view::DMatrixView">DMatrixView</a><'_, N, <a class="struct" href="https://docs.rs/nalgebra/0.25.0/nalgebra/base/dimension/struct.Dyn.html" title="struct nalgebra::base::dimension::Dyn">Dyn</a>, <a class="struct" href="https://docs.rs/nalgebra/0.25.0/nalgebra/base/dimension/struct.Dyn.html" title="struct nalgebra::base::dimension::Dyn">Dyn</a>></h4></section></summary><div class="docblock"><p>Convert this two-dimensional array into a <a href="https://docs.rs/nalgebra/0.25.0/nalgebra/base/alias_view/type.DMatrixView.html" title="type nalgebra::base::alias_view::DMatrixView"><code>nalgebra::DMatrixView</code></a> using dynamic strides.</p>
<h5 id="panics-1"><a href="#panics-1">Panics</a></h5>
<p>Panics if the array has negative strides.</p>
</div></details></div></details></div><h2 id="deref-methods-PyArray%3CT,+D%3E" class="section-header"><span>Methods from <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/ops/deref/trait.Deref.html" title="trait core::ops::deref::Deref">Deref</a><Target = <a class="struct" href="../array/struct.PyArray.html" title="struct numpy::array::PyArray">PyArray</a><T, D>></span><a href="#deref-methods-PyArray%3CT,+D%3E" class="anchor">§</a></h2><div id="deref-methods-PyArray%3CT,+D%3E-1" class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.as_untyped" class="method"><a class="src rightside" href="../../src/numpy/array.rs.html#204-206">source</a><h4 class="code-header">pub fn <a href="#method.as_untyped" class="fn">as_untyped</a>(&self) -> &<a class="struct" href="../struct.PyUntypedArray.html" title="struct numpy::PyUntypedArray">PyUntypedArray</a></h4></section></summary><div class="docblock"><p>Access an untyped representation of this array.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.to_owned" class="method"><a class="src rightside" href="../../src/numpy/array.rs.html#228-230">source</a><h4 class="code-header">pub fn <a href="#method.to_owned" class="fn">to_owned</a>(&self) -> Py<Self></h4></section></summary><div class="docblock"><p>Turn <code>&PyArray<T,D></code> into <code>Py<PyArray<T,D>></code>,
i.e. a pointer into Python’s heap which is independent of the GIL lifetime.</p>
<p>This method can be used to avoid lifetime annotations of function arguments
or return values.</p>
<h5 id="example"><a href="#example">Example</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>numpy::PyArray1;
<span class="kw">use </span>pyo3::{Py, Python};
<span class="kw">let </span>array: Py<PyArray1<f64>> = Python::with_gil(|py| {
PyArray1::zeros(py, <span class="number">5</span>, <span class="bool-val">false</span>).to_owned()
});
Python::with_gil(|py| {
<span class="macro">assert_eq!</span>(array.as_ref(py).readonly().as_slice().unwrap(), [<span class="number">0.0</span>; <span class="number">5</span>]);
});</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.data" class="method"><a class="src rightside" href="../../src/numpy/array.rs.html#252-254">source</a><h4 class="code-header">pub fn <a href="#method.data" class="fn">data</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.pointer.html">*mut T</a></h4></section></summary><div class="docblock"><p>Returns a pointer to the first element of the array.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.dims" class="method"><a class="src rightside" href="../../src/numpy/array.rs.html#292-294">source</a><h4 class="code-header">pub fn <a href="#method.dims" class="fn">dims</a>(&self) -> D</h4></section></summary><div class="docblock"><p>Same as <a href="../struct.PyUntypedArray.html#method.shape" title="method numpy::PyUntypedArray::shape"><code>shape</code></a>, but returns <code>D</code> instead of <code>&[usize]</code>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.as_slice-1" class="method"><a class="src rightside" href="../../src/numpy/array.rs.html#519-525">source</a><h4 class="code-header">pub unsafe fn <a href="#method.as_slice-1" class="fn">as_slice</a>(&self) -> <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><&<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.slice.html">[T]</a>, <a class="struct" href="../struct.NotContiguousError.html" title="struct numpy::NotContiguousError">NotContiguousError</a>></h4></section></summary><div class="docblock"><p>Returns an immutable view of the internal data as a slice.</p>
<h5 id="safety"><a href="#safety">Safety</a></h5>
<p>Calling this method is undefined behaviour if the underlying array
is aliased mutably by other instances of <code>PyArray</code>
or concurrently modified by Python or other native code.</p>
<p>Please consider the safe alternative <a href="struct.PyReadonlyArray.html#method.as_slice" title="method numpy::borrow::PyReadonlyArray::as_slice"><code>PyReadonlyArray::as_slice</code></a>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.as_slice_mut" class="method"><a class="src rightside" href="../../src/numpy/array.rs.html#536-542">source</a><h4 class="code-header">pub unsafe fn <a href="#method.as_slice_mut" class="fn">as_slice_mut</a>(&self) -> <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><&mut <a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.slice.html">[T]</a>, <a class="struct" href="../struct.NotContiguousError.html" title="struct numpy::NotContiguousError">NotContiguousError</a>></h4></section></summary><div class="docblock"><p>Returns a mutable view of the internal data as a slice.</p>
<h5 id="safety-1"><a href="#safety-1">Safety</a></h5>
<p>Calling this method is undefined behaviour if the underlying array
is aliased immutably or mutably by other instances of <a href="../array/struct.PyArray.html" title="struct numpy::array::PyArray"><code>PyArray</code></a>
or concurrently modified by Python or other native code.</p>
<p>Please consider the safe alternative <a href="struct.PyReadwriteArray.html#method.as_slice_mut" title="method numpy::borrow::PyReadwriteArray::as_slice_mut"><code>PyReadwriteArray::as_slice_mut</code></a>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.get-1" class="method"><a class="src rightside" href="../../src/numpy/array.rs.html#598-601">source</a><h4 class="code-header">pub unsafe fn <a href="#method.get-1" class="fn">get</a>(&self, index: impl <a class="trait" href="../convert/trait.NpyIndex.html" title="trait numpy::convert::NpyIndex">NpyIndex</a><Dim = D>) -> <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.reference.html">&T</a>></h4></section></summary><div class="docblock"><p>Get a reference of the specified element if the given index is valid.</p>
<h5 id="safety-2"><a href="#safety-2">Safety</a></h5>
<p>Calling this method is undefined behaviour if the underlying array
is aliased mutably by other instances of <code>PyArray</code>
or concurrently modified by Python or other native code.</p>
<p>Consider using safe alternatives like <a href="struct.PyReadonlyArray.html#method.get" title="method numpy::borrow::PyReadonlyArray::get"><code>PyReadonlyArray::get</code></a>.</p>
<h5 id="example-1"><a href="#example-1">Example</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>numpy::PyArray;
<span class="kw">use </span>pyo3::Python;
Python::with_gil(|py| {
<span class="kw">let </span>pyarray = PyArray::arange(py, <span class="number">0</span>, <span class="number">16</span>, <span class="number">1</span>).reshape([<span class="number">2</span>, <span class="number">2</span>, <span class="number">4</span>]).unwrap();
<span class="macro">assert_eq!</span>(<span class="kw">unsafe </span>{ <span class="kw-2">*</span>pyarray.get([<span class="number">1</span>, <span class="number">0</span>, <span class="number">3</span>]).unwrap() }, <span class="number">11</span>);
});</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.get_mut" class="method"><a class="src rightside" href="../../src/numpy/array.rs.html#630-633">source</a><h4 class="code-header">pub unsafe fn <a href="#method.get_mut" class="fn">get_mut</a>(&self, index: impl <a class="trait" href="../convert/trait.NpyIndex.html" title="trait numpy::convert::NpyIndex">NpyIndex</a><Dim = D>) -> <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.reference.html">&mut T</a>></h4></section></summary><div class="docblock"><p>Same as <a href="../array/struct.PyArray.html#method.get" title="method numpy::array::PyArray::get"><code>get</code></a>, but returns <code>Option<&mut T></code>.</p>
<h5 id="safety-3"><a href="#safety-3">Safety</a></h5>
<p>Calling this method is undefined behaviour if the underlying array
is aliased immutably or mutably by other instances of <a href="../array/struct.PyArray.html" title="struct numpy::array::PyArray"><code>PyArray</code></a>
or concurrently modified by Python or other native code.</p>
<p>Consider using safe alternatives like <a href="struct.PyReadwriteArray.html#method.get_mut" title="method numpy::borrow::PyReadwriteArray::get_mut"><code>PyReadwriteArray::get_mut</code></a>.</p>
<h5 id="example-2"><a href="#example-2">Example</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>numpy::PyArray;
<span class="kw">use </span>pyo3::Python;
Python::with_gil(|py| {
<span class="kw">let </span>pyarray = PyArray::arange(py, <span class="number">0</span>, <span class="number">16</span>, <span class="number">1</span>).reshape([<span class="number">2</span>, <span class="number">2</span>, <span class="number">4</span>]).unwrap();
<span class="kw">unsafe </span>{
<span class="kw-2">*</span>pyarray.get_mut([<span class="number">1</span>, <span class="number">0</span>, <span class="number">3</span>]).unwrap() = <span class="number">42</span>;
}
<span class="macro">assert_eq!</span>(<span class="kw">unsafe </span>{ <span class="kw-2">*</span>pyarray.get([<span class="number">1</span>, <span class="number">0</span>, <span class="number">3</span>]).unwrap() }, <span class="number">42</span>);
});</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.uget" class="method"><a class="src rightside" href="../../src/numpy/array.rs.html#670-675">source</a><h4 class="code-header">pub unsafe fn <a href="#method.uget" class="fn">uget</a><Idx>(&self, index: Idx) -> <a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.reference.html">&T</a><div class="where">where
Idx: <a class="trait" href="../convert/trait.NpyIndex.html" title="trait numpy::convert::NpyIndex">NpyIndex</a><Dim = D>,</div></h4></section></summary><div class="docblock"><p>Get an immutable reference of the specified element,
without checking the given index.</p>
<p>See <a href="../convert/trait.NpyIndex.html" title="trait numpy::convert::NpyIndex"><code>NpyIndex</code></a> for what types can be used as the index.</p>
<h5 id="safety-4"><a href="#safety-4">Safety</a></h5>
<p>Passing an invalid index is undefined behavior.
The element must also have been initialized and
all other references to it is must also be shared.</p>
<p>See <a href="struct.PyReadonlyArray.html#method.get" title="method numpy::borrow::PyReadonlyArray::get"><code>PyReadonlyArray::get</code></a> for a safe alternative.</p>
<h5 id="example-3"><a href="#example-3">Example</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>numpy::PyArray;
<span class="kw">use </span>pyo3::Python;
Python::with_gil(|py| {
<span class="kw">let </span>pyarray = PyArray::arange(py, <span class="number">0</span>, <span class="number">16</span>, <span class="number">1</span>).reshape([<span class="number">2</span>, <span class="number">2</span>, <span class="number">4</span>]).unwrap();
<span class="macro">assert_eq!</span>(<span class="kw">unsafe </span>{ <span class="kw-2">*</span>pyarray.uget([<span class="number">1</span>, <span class="number">0</span>, <span class="number">3</span>]) }, <span class="number">11</span>);
});</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.uget_mut" class="method"><a class="src rightside" href="../../src/numpy/array.rs.html#688-693">source</a><h4 class="code-header">pub unsafe fn <a href="#method.uget_mut" class="fn">uget_mut</a><Idx>(&self, index: Idx) -> <a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.reference.html">&mut T</a><div class="where">where
Idx: <a class="trait" href="../convert/trait.NpyIndex.html" title="trait numpy::convert::NpyIndex">NpyIndex</a><Dim = D>,</div></h4></section></summary><div class="docblock"><p>Same as <a href="../array/struct.PyArray.html#method.uget" title="method numpy::array::PyArray::uget"><code>uget</code></a>, but returns <code>&mut T</code>.</p>
<h5 id="safety-5"><a href="#safety-5">Safety</a></h5>
<p>Passing an invalid index is undefined behavior.
The element must also have been initialized and
other references to it must not exist.</p>
<p>See <a href="struct.PyReadwriteArray.html#method.get_mut" title="method numpy::borrow::PyReadwriteArray::get_mut"><code>PyReadwriteArray::get_mut</code></a> for a safe alternative.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.uget_raw" class="method"><a class="src rightside" href="../../src/numpy/array.rs.html#701-707">source</a><h4 class="code-header">pub unsafe fn <a href="#method.uget_raw" class="fn">uget_raw</a><Idx>(&self, index: Idx) -> <a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.pointer.html">*mut T</a><div class="where">where
Idx: <a class="trait" href="../convert/trait.NpyIndex.html" title="trait numpy::convert::NpyIndex">NpyIndex</a><Dim = D>,</div></h4></section></summary><div class="docblock"><p>Same as <a href="../array/struct.PyArray.html#method.uget" title="method numpy::array::PyArray::uget"><code>uget</code></a>, but returns <code>*mut T</code>.</p>
<h5 id="safety-6"><a href="#safety-6">Safety</a></h5>
<p>Passing an invalid index is undefined behavior.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.get_owned" class="method"><a class="src rightside" href="../../src/numpy/array.rs.html#724-729">source</a><h4 class="code-header">pub fn <a href="#method.get_owned" class="fn">get_owned</a><Idx>(&self, index: Idx) -> <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a><T><div class="where">where
Idx: <a class="trait" href="../convert/trait.NpyIndex.html" title="trait numpy::convert::NpyIndex">NpyIndex</a><Dim = D>,</div></h4></section></summary><div class="docblock"><p>Get a copy of the specified element in the array.</p>
<p>See <a href="../convert/trait.NpyIndex.html" title="trait numpy::convert::NpyIndex"><code>NpyIndex</code></a> for what types can be used as the index.</p>
<h5 id="example-4"><a href="#example-4">Example</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>numpy::PyArray;
<span class="kw">use </span>pyo3::Python;
Python::with_gil(|py| {
<span class="kw">let </span>pyarray = PyArray::arange(py, <span class="number">0</span>, <span class="number">16</span>, <span class="number">1</span>).reshape([<span class="number">2</span>, <span class="number">2</span>, <span class="number">4</span>]).unwrap();
<span class="macro">assert_eq!</span>(pyarray.get_owned([<span class="number">1</span>, <span class="number">0</span>, <span class="number">3</span>]), <span class="prelude-val">Some</span>(<span class="number">11</span>));
});</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.to_dyn" class="method"><a class="src rightside" href="../../src/numpy/array.rs.html#732-734">source</a><h4 class="code-header">pub fn <a href="#method.to_dyn" class="fn">to_dyn</a>(&self) -> &<a class="struct" href="../array/struct.PyArray.html" title="struct numpy::array::PyArray">PyArray</a><T, <a class="type" href="../type.IxDyn.html" title="type numpy::IxDyn">IxDyn</a>></h4></section></summary><div class="docblock"><p>Turn an array with fixed dimensionality into one with dynamic dimensionality.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.to_vec" class="method"><a class="src rightside" href="../../src/numpy/array.rs.html#756-758">source</a><h4 class="code-header">pub fn <a href="#method.to_vec" class="fn">to_vec</a>(&self) -> <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="struct" href="https://doc.rust-lang.org/1.76.0/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a><T>, <a class="struct" href="../struct.NotContiguousError.html" title="struct numpy::NotContiguousError">NotContiguousError</a>></h4></section></summary><div class="docblock"><p>Returns a copy of the internal data of the array as a <a href="https://doc.rust-lang.org/1.76.0/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec"><code>Vec</code></a>.</p>
<p>Fails if the internal array is not contiguous. See also <a href="../array/struct.PyArray.html#method.as_slice" title="method numpy::array::PyArray::as_slice"><code>as_slice</code></a>.</p>
<h5 id="example-5"><a href="#example-5">Example</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>numpy::PyArray2;
<span class="kw">use </span>pyo3::Python;
Python::with_gil(|py| {
<span class="kw">let </span>pyarray= py
.eval(<span class="string">"__import__('numpy').array([[0, 1], [2, 3]], dtype='int64')"</span>, <span class="prelude-val">None</span>, <span class="prelude-val">None</span>)
.unwrap()
.downcast::<PyArray2<i64>>()
.unwrap();
<span class="macro">assert_eq!</span>(pyarray.to_vec().unwrap(), <span class="macro">vec!</span>[<span class="number">0</span>, <span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>]);
});</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.try_readonly" class="method"><a class="src rightside" href="../../src/numpy/array.rs.html#786-788">source</a><h4 class="code-header">pub fn <a href="#method.try_readonly" class="fn">try_readonly</a>(&self) -> <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="struct" href="struct.PyReadonlyArray.html" title="struct numpy::borrow::PyReadonlyArray">PyReadonlyArray</a><'_, T, D>, <a class="enum" href="../enum.BorrowError.html" title="enum numpy::BorrowError">BorrowError</a>></h4></section></summary><div class="docblock"><p>Get an immutable borrow of the NumPy array</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.readonly" class="method"><a class="src rightside" href="../../src/numpy/array.rs.html#797-799">source</a><h4 class="code-header">pub fn <a href="#method.readonly" class="fn">readonly</a>(&self) -> <a class="struct" href="struct.PyReadonlyArray.html" title="struct numpy::borrow::PyReadonlyArray">PyReadonlyArray</a><'_, T, D></h4></section></summary><div class="docblock"><p>Get an immutable borrow of the NumPy array</p>
<h5 id="panics-2"><a href="#panics-2">Panics</a></h5>
<p>Panics if the allocation backing the array is currently mutably borrowed.</p>
<p>For a non-panicking variant, use <a href="../array/struct.PyArray.html#method.try_readonly" title="method numpy::array::PyArray::try_readonly"><code>try_readonly</code></a>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.try_readwrite" class="method"><a class="src rightside" href="../../src/numpy/array.rs.html#802-804">source</a><h4 class="code-header">pub fn <a href="#method.try_readwrite" class="fn">try_readwrite</a>(&self) -> <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="struct" href="struct.PyReadwriteArray.html" title="struct numpy::borrow::PyReadwriteArray">PyReadwriteArray</a><'_, T, D>, <a class="enum" href="../enum.BorrowError.html" title="enum numpy::BorrowError">BorrowError</a>></h4></section></summary><div class="docblock"><p>Get a mutable borrow of the NumPy array</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.readwrite" class="method"><a class="src rightside" href="../../src/numpy/array.rs.html#816-818">source</a><h4 class="code-header">pub fn <a href="#method.readwrite" class="fn">readwrite</a>(&self) -> <a class="struct" href="struct.PyReadwriteArray.html" title="struct numpy::borrow::PyReadwriteArray">PyReadwriteArray</a><'_, T, D></h4></section></summary><div class="docblock"><p>Get a mutable borrow of the NumPy array</p>
<h5 id="panics-3"><a href="#panics-3">Panics</a></h5>
<p>Panics if the allocation backing the array is currently borrowed or
if the array is <a href="https://numpy.org/doc/stable/reference/generated/numpy.ndarray.flags.html">flagged as</a> not writeable.</p>
<p>For a non-panicking variant, use <a href="../array/struct.PyArray.html#method.try_readwrite" title="method numpy::array::PyArray::try_readwrite"><code>try_readwrite</code></a>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.as_array-1" class="method"><a class="src rightside" href="../../src/numpy/array.rs.html#881-883">source</a><h4 class="code-header">pub unsafe fn <a href="#method.as_array-1" class="fn">as_array</a>(&self) -> <a class="type" href="https://docs.rs/ndarray/0.15/ndarray/type.ArrayView.html" title="type ndarray::ArrayView">ArrayView</a><'_, T, D></h4></section></summary><div class="docblock"><p>Returns an <a href="https://docs.rs/ndarray/0.15/ndarray/type.ArrayView.html" title="type ndarray::ArrayView"><code>ArrayView</code></a> of the internal array.</p>
<p>See also <a href="struct.PyReadonlyArray.html#method.as_array" title="method numpy::borrow::PyReadonlyArray::as_array"><code>PyReadonlyArray::as_array</code></a>.</p>
<h5 id="safety-7"><a href="#safety-7">Safety</a></h5>
<p>Calling this method invalidates all exclusive references to the internal data, e.g. <code>&mut [T]</code> or <code>ArrayViewMut</code>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.as_array_mut" class="method"><a class="src rightside" href="../../src/numpy/array.rs.html#892-894">source</a><h4 class="code-header">pub unsafe fn <a href="#method.as_array_mut" class="fn">as_array_mut</a>(&self) -> <a class="type" href="https://docs.rs/ndarray/0.15/ndarray/type.ArrayViewMut.html" title="type ndarray::ArrayViewMut">ArrayViewMut</a><'_, T, D></h4></section></summary><div class="docblock"><p>Returns an <a href="https://docs.rs/ndarray/0.15/ndarray/type.ArrayViewMut.html" title="type ndarray::ArrayViewMut"><code>ArrayViewMut</code></a> of the internal array.</p>
<p>See also <a href="struct.PyReadwriteArray.html#method.as_array_mut" title="method numpy::borrow::PyReadwriteArray::as_array_mut"><code>PyReadwriteArray::as_array_mut</code></a>.</p>
<h5 id="safety-8"><a href="#safety-8">Safety</a></h5>
<p>Calling this method invalidates all other references to the internal data, e.g. <code>ArrayView</code> or <code>ArrayViewMut</code>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.as_raw_array" class="method"><a class="src rightside" href="../../src/numpy/array.rs.html#897-899">source</a><h4 class="code-header">pub fn <a href="#method.as_raw_array" class="fn">as_raw_array</a>(&self) -> <a class="type" href="https://docs.rs/ndarray/0.15/ndarray/type.RawArrayView.html" title="type ndarray::RawArrayView">RawArrayView</a><T, D></h4></section></summary><div class="docblock"><p>Returns the internal array as <a href="https://docs.rs/ndarray/0.15/ndarray/type.RawArrayView.html" title="type ndarray::RawArrayView"><code>RawArrayView</code></a> enabling element access via raw pointers</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.as_raw_array_mut" class="method"><a class="src rightside" href="../../src/numpy/array.rs.html#902-904">source</a><h4 class="code-header">pub fn <a href="#method.as_raw_array_mut" class="fn">as_raw_array_mut</a>(&self) -> <a class="type" href="https://docs.rs/ndarray/0.15/ndarray/type.RawArrayViewMut.html" title="type ndarray::RawArrayViewMut">RawArrayViewMut</a><T, D></h4></section></summary><div class="docblock"><p>Returns the internal array as <a href="https://docs.rs/ndarray/0.15/ndarray/type.RawArrayViewMut.html" title="type ndarray::RawArrayViewMut"><code>RawArrayViewMut</code></a> enabling element access via raw pointers</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.to_owned_array" class="method"><a class="src rightside" href="../../src/numpy/array.rs.html#924-926">source</a><h4 class="code-header">pub fn <a href="#method.to_owned_array" class="fn">to_owned_array</a>(&self) -> <a class="type" href="https://docs.rs/ndarray/0.15/ndarray/type.Array.html" title="type ndarray::Array">Array</a><T, D></h4></section></summary><div class="docblock"><p>Get a copy of the array as an <a href="https://docs.rs/ndarray/0.15/ndarray/type.Array.html" title="type ndarray::Array"><code>ndarray::Array</code></a>.</p>
<h5 id="example-6"><a href="#example-6">Example</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>numpy::PyArray;
<span class="kw">use </span>ndarray::array;
<span class="kw">use </span>pyo3::Python;
Python::with_gil(|py| {
<span class="kw">let </span>pyarray = PyArray::arange(py, <span class="number">0</span>, <span class="number">4</span>, <span class="number">1</span>).reshape([<span class="number">2</span>, <span class="number">2</span>]).unwrap();
<span class="macro">assert_eq!</span>(
pyarray.to_owned_array(),
<span class="macro">array!</span>[[<span class="number">0</span>, <span class="number">1</span>], [<span class="number">2</span>, <span class="number">3</span>]]
)
});</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.try_as_matrix-1" class="method"><a class="src rightside" href="../../src/numpy/array.rs.html#996-1010">source</a><h4 class="code-header">pub unsafe fn <a href="#method.try_as_matrix-1" class="fn">try_as_matrix</a><R, C, RStride, CStride>(
&self
) -> <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="type" href="https://docs.rs/nalgebra/0.25.0/nalgebra/base/matrix_view/type.MatrixView.html" title="type nalgebra::base::matrix_view::MatrixView">MatrixView</a><'_, N, R, C, RStride, CStride>><div class="where">where
R: <a class="trait" href="https://docs.rs/nalgebra/0.25.0/nalgebra/base/dimension/trait.Dim.html" title="trait nalgebra::base::dimension::Dim">Dim</a>,
C: <a class="trait" href="https://docs.rs/nalgebra/0.25.0/nalgebra/base/dimension/trait.Dim.html" title="trait nalgebra::base::dimension::Dim">Dim</a>,
RStride: <a class="trait" href="https://docs.rs/nalgebra/0.25.0/nalgebra/base/dimension/trait.Dim.html" title="trait nalgebra::base::dimension::Dim">Dim</a>,
CStride: <a class="trait" href="https://docs.rs/nalgebra/0.25.0/nalgebra/base/dimension/trait.Dim.html" title="trait nalgebra::base::dimension::Dim">Dim</a>,</div></h4></section></summary><div class="docblock"><p>Try to convert this array into a <a href="https://docs.rs/nalgebra/0.25.0/nalgebra/base/matrix_view/type.MatrixView.html" title="type nalgebra::base::matrix_view::MatrixView"><code>nalgebra::MatrixView</code></a> using the given shape and strides.</p>
<h5 id="safety-9"><a href="#safety-9">Safety</a></h5>
<p>Calling this method invalidates all exclusive references to the internal data, e.g. <code>ArrayViewMut</code> or <code>MatrixSliceMut</code>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.try_as_matrix_mut" class="method"><a class="src rightside" href="../../src/numpy/array.rs.html#1018-1032">source</a><h4 class="code-header">pub unsafe fn <a href="#method.try_as_matrix_mut" class="fn">try_as_matrix_mut</a><R, C, RStride, CStride>(
&self
) -> <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="type" href="https://docs.rs/nalgebra/0.25.0/nalgebra/base/matrix_view/type.MatrixViewMut.html" title="type nalgebra::base::matrix_view::MatrixViewMut">MatrixViewMut</a><'_, N, R, C, RStride, CStride>><div class="where">where
R: <a class="trait" href="https://docs.rs/nalgebra/0.25.0/nalgebra/base/dimension/trait.Dim.html" title="trait nalgebra::base::dimension::Dim">Dim</a>,
C: <a class="trait" href="https://docs.rs/nalgebra/0.25.0/nalgebra/base/dimension/trait.Dim.html" title="trait nalgebra::base::dimension::Dim">Dim</a>,
RStride: <a class="trait" href="https://docs.rs/nalgebra/0.25.0/nalgebra/base/dimension/trait.Dim.html" title="trait nalgebra::base::dimension::Dim">Dim</a>,
CStride: <a class="trait" href="https://docs.rs/nalgebra/0.25.0/nalgebra/base/dimension/trait.Dim.html" title="trait nalgebra::base::dimension::Dim">Dim</a>,</div></h4></section></summary><div class="docblock"><p>Try to convert this array into a <a href="https://docs.rs/nalgebra/0.25.0/nalgebra/base/matrix_view/type.MatrixViewMut.html" title="type nalgebra::base::matrix_view::MatrixViewMut"><code>nalgebra::MatrixViewMut</code></a> using the given shape and strides.</p>
<h5 id="safety-10"><a href="#safety-10">Safety</a></h5>
<p>Calling this method invalidates all other references to the internal data, e.g. <code>ArrayView</code>, <code>MatrixSlice</code>, <code>ArrayViewMut</code> or <code>MatrixSliceMut</code>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.item" class="method"><a class="src rightside" href="../../src/numpy/array.rs.html#1089-1091">source</a><h4 class="code-header">pub fn <a href="#method.item" class="fn">item</a>(&self) -> T</h4></section></summary><div class="docblock"><p>Get the single element of a zero-dimensional array.</p>
<p>See <a href="../fn.inner.html" title="fn numpy::inner"><code>inner</code></a> for an example.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.copy_to" class="method"><a class="src rightside" href="../../src/numpy/array.rs.html#1282-1291">source</a><h4 class="code-header">pub fn <a href="#method.copy_to" class="fn">copy_to</a><U: <a class="trait" href="../trait.Element.html" title="trait numpy::Element">Element</a>>(&self, other: &<a class="struct" href="../array/struct.PyArray.html" title="struct numpy::array::PyArray">PyArray</a><U, D>) -> PyResult<<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.unit.html">()</a>></h4></section></summary><div class="docblock"><p>Copies <code>self</code> into <code>other</code>, performing a data type conversion if necessary.</p>
<p>See also <a href="https://numpy.org/doc/stable/reference/c-api/array.html#c.PyArray_CopyInto"><code>PyArray_CopyInto</code></a>.</p>
<h5 id="example-7"><a href="#example-7">Example</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>numpy::PyArray;
<span class="kw">use </span>pyo3::Python;
Python::with_gil(|py| {
<span class="kw">let </span>pyarray_f = PyArray::arange(py, <span class="number">2.0</span>, <span class="number">5.0</span>, <span class="number">1.0</span>);
<span class="kw">let </span>pyarray_i = <span class="kw">unsafe </span>{ PyArray::<i64, <span class="kw">_</span>>::new(py, [<span class="number">3</span>], <span class="bool-val">false</span>) };
<span class="macro">assert!</span>(pyarray_f.copy_to(pyarray_i).is_ok());
<span class="macro">assert_eq!</span>(pyarray_i.readonly().as_slice().unwrap(), <span class="kw-2">&</span>[<span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>]);
});</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.cast" class="method"><a class="src rightside" href="../../src/numpy/array.rs.html#1313-1327">source</a><h4 class="code-header">pub fn <a href="#method.cast" class="fn">cast</a><'py, U: <a class="trait" href="../trait.Element.html" title="trait numpy::Element">Element</a>>(
&'py self,
is_fortran: <a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.bool.html">bool</a>
) -> PyResult<&'py <a class="struct" href="../array/struct.PyArray.html" title="struct numpy::array::PyArray">PyArray</a><U, D>></h4></section></summary><div class="docblock"><p>Cast the <code>PyArray<T></code> to <code>PyArray<U></code>, by allocating a new array.</p>
<p>See also <a href="https://numpy.org/doc/stable/reference/c-api/array.html#c.PyArray_CastToType"><code>PyArray_CastToType</code></a>.</p>
<h5 id="example-8"><a href="#example-8">Example</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>numpy::PyArray;
<span class="kw">use </span>pyo3::Python;
Python::with_gil(|py| {
<span class="kw">let </span>pyarray_f = PyArray::arange(py, <span class="number">2.0</span>, <span class="number">5.0</span>, <span class="number">1.0</span>);
<span class="kw">let </span>pyarray_i = pyarray_f.cast::<i32>(<span class="bool-val">false</span>).unwrap();
<span class="macro">assert_eq!</span>(pyarray_i.readonly().as_slice().unwrap(), <span class="kw-2">&</span>[<span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>]);
});</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.reshape_with_order" class="method"><a class="src rightside" href="../../src/numpy/array.rs.html#1355-1375">source</a><h4 class="code-header">pub fn <a href="#method.reshape_with_order" class="fn">reshape_with_order</a><'py, ID: <a class="trait" href="https://docs.rs/ndarray/0.15/ndarray/dimension/conversion/trait.IntoDimension.html" title="trait ndarray::dimension::conversion::IntoDimension">IntoDimension</a>>(
&'py self,
dims: ID,
order: <a class="enum" href="../npyffi/types/enum.NPY_ORDER.html" title="enum numpy::npyffi::types::NPY_ORDER">NPY_ORDER</a>
) -> PyResult<&'py <a class="struct" href="../array/struct.PyArray.html" title="struct numpy::array::PyArray">PyArray</a><T, ID::<a class="associatedtype" href="https://docs.rs/ndarray/0.15/ndarray/dimension/conversion/trait.IntoDimension.html#associatedtype.Dim" title="type ndarray::dimension::conversion::IntoDimension::Dim">Dim</a>>></h4></section></summary><div class="docblock"><p>Construct a new array which has same values as self,
but has different dimensions specified by <code>dims</code>
and a possibly different memory order specified by <code>order</code>.</p>
<p>See also <a href="https://numpy.org/doc/stable/reference/generated/numpy.reshape.html"><code>numpy.reshape</code></a> and <a href="https://numpy.org/doc/stable/reference/c-api/array.html#c.PyArray_Newshape"><code>PyArray_Newshape</code></a>.</p>
<h5 id="example-9"><a href="#example-9">Example</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>numpy::{npyffi::NPY_ORDER, PyArray};
<span class="kw">use </span>pyo3::Python;
<span class="kw">use </span>ndarray::array;
Python::with_gil(|py| {
<span class="kw">let </span>array =
PyArray::from_iter(py, <span class="number">0</span>..<span class="number">9</span>).reshape_with_order([<span class="number">3</span>, <span class="number">3</span>], NPY_ORDER::NPY_FORTRANORDER).unwrap();
<span class="macro">assert_eq!</span>(array.readonly().as_array(), <span class="macro">array!</span>[[<span class="number">0</span>, <span class="number">3</span>, <span class="number">6</span>], [<span class="number">1</span>, <span class="number">4</span>, <span class="number">7</span>], [<span class="number">2</span>, <span class="number">5</span>, <span class="number">8</span>]]);
<span class="macro">assert!</span>(array.is_fortran_contiguous());
<span class="macro">assert!</span>(array.reshape([<span class="number">5</span>]).is_err());
});</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.reshape" class="method"><a class="src rightside" href="../../src/numpy/array.rs.html#1379-1384">source</a><h4 class="code-header">pub fn <a href="#method.reshape" class="fn">reshape</a><'py, ID: <a class="trait" href="https://docs.rs/ndarray/0.15/ndarray/dimension/conversion/trait.IntoDimension.html" title="trait ndarray::dimension::conversion::IntoDimension">IntoDimension</a>>(
&'py self,
dims: ID
) -> PyResult<&'py <a class="struct" href="../array/struct.PyArray.html" title="struct numpy::array::PyArray">PyArray</a><T, ID::<a class="associatedtype" href="https://docs.rs/ndarray/0.15/ndarray/dimension/conversion/trait.IntoDimension.html#associatedtype.Dim" title="type ndarray::dimension::conversion::IntoDimension::Dim">Dim</a>>></h4></section></summary><div class="docblock"><p>Special case of <a href="../array/struct.PyArray.html#method.reshape_with_order" title="method numpy::array::PyArray::reshape_with_order"><code>reshape_with_order</code></a> which keeps the memory order the same.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.resize" class="method"><a class="src rightside" href="../../src/numpy/array.rs.html#1417-1432">source</a><h4 class="code-header">pub unsafe fn <a href="#method.resize" class="fn">resize</a><ID: <a class="trait" href="https://docs.rs/ndarray/0.15/ndarray/dimension/conversion/trait.IntoDimension.html" title="trait ndarray::dimension::conversion::IntoDimension">IntoDimension</a>>(&self, dims: ID) -> PyResult<<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.unit.html">()</a>></h4></section></summary><div class="docblock"><p>Extends or truncates the dimensions of an array.</p>
<p>This method works only on <a href="../struct.PyUntypedArray.html#method.is_contiguous" title="method numpy::PyUntypedArray::is_contiguous">contiguous</a> arrays.
Missing elements will be initialized as if calling <a href="../array/struct.PyArray.html#method.zeros" title="associated function numpy::array::PyArray::zeros"><code>zeros</code></a>.</p>
<p>See also <a href="https://numpy.org/doc/stable/reference/generated/numpy.ndarray.resize.html"><code>ndarray.resize</code></a> and <a href="https://numpy.org/doc/stable/reference/c-api/array.html#c.PyArray_Resize"><code>PyArray_Resize</code></a>.</p>
<h5 id="safety-11"><a href="#safety-11">Safety</a></h5>
<p>There should be no outstanding references (shared or exclusive) into the array
as this method might re-allocate it and thereby invalidate all pointers into it.</p>
<h5 id="example-10"><a href="#example-10">Example</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>numpy::PyArray;
<span class="kw">use </span>pyo3::Python;
Python::with_gil(|py| {
<span class="kw">let </span>pyarray = PyArray::<f64, <span class="kw">_</span>>::zeros(py, (<span class="number">10</span>, <span class="number">10</span>), <span class="bool-val">false</span>);
<span class="macro">assert_eq!</span>(pyarray.shape(), [<span class="number">10</span>, <span class="number">10</span>]);
<span class="kw">unsafe </span>{
pyarray.resize((<span class="number">100</span>, <span class="number">100</span>)).unwrap();
}
<span class="macro">assert_eq!</span>(pyarray.shape(), [<span class="number">100</span>, <span class="number">100</span>]);
});</code></pre></div>
</div></details></div><h2 id="deref-methods-PyUntypedArray" class="section-header"><span>Methods from <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/ops/deref/trait.Deref.html" title="trait core::ops::deref::Deref">Deref</a><Target = <a class="struct" href="../struct.PyUntypedArray.html" title="struct numpy::PyUntypedArray">PyUntypedArray</a>></span><a href="#deref-methods-PyUntypedArray" class="anchor">§</a></h2><div id="deref-methods-PyUntypedArray-1" class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.as_array_ptr" class="method"><a class="src rightside" href="../../src/numpy/untyped_array.rs.html#90-92">source</a><h4 class="code-header">pub fn <a href="#method.as_array_ptr" class="fn">as_array_ptr</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.pointer.html">*mut </a><a class="struct" href="../npyffi/objects/struct.PyArrayObject.html" title="struct numpy::npyffi::objects::PyArrayObject">PyArrayObject</a></h4></section></summary><div class="docblock"><p>Returns a raw pointer to the underlying <a href="../npyffi/objects/struct.PyArrayObject.html" title="struct numpy::npyffi::objects::PyArrayObject"><code>PyArrayObject</code></a>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.dtype" class="method"><a class="src rightside" href="../../src/numpy/untyped_array.rs.html#114-116">source</a><h4 class="code-header">pub fn <a href="#method.dtype" class="fn">dtype</a>(&self) -> &<a class="struct" href="../struct.PyArrayDescr.html" title="struct numpy::PyArrayDescr">PyArrayDescr</a></h4></section></summary><div class="docblock"><p>Returns the <code>dtype</code> of the array.</p>
<p>See also <a href="https://numpy.org/doc/stable/reference/generated/numpy.ndarray.dtype.html"><code>ndarray.dtype</code></a> and <a href="https://numpy.org/doc/stable/reference/c-api/array.html#c.PyArray_DTYPE"><code>PyArray_DTYPE</code></a>.</p>
<h5 id="example-11"><a href="#example-11">Example</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>numpy::{dtype_bound, PyArray};
<span class="kw">use </span>pyo3::Python;
Python::with_gil(|py| {
<span class="kw">let </span>array = PyArray::from_vec(py, <span class="macro">vec!</span>[<span class="number">1_i32</span>, <span class="number">2</span>, <span class="number">3</span>]);
<span class="macro">assert!</span>(array.dtype().is_equiv_to(dtype_bound::<i32>(py).as_gil_ref()));
});</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.is_contiguous" class="method"><a class="src rightside" href="../../src/numpy/untyped_array.rs.html#140-142">source</a><h4 class="code-header">pub fn <a href="#method.is_contiguous" class="fn">is_contiguous</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.bool.html">bool</a></h4></section></summary><div class="docblock"><p>Returns <code>true</code> if the internal data of the array is contiguous,
indepedently of whether C-style/row-major or Fortran-style/column-major.</p>
<h5 id="example-12"><a href="#example-12">Example</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>numpy::PyArray1;
<span class="kw">use </span>pyo3::{types::IntoPyDict, Python};
Python::with_gil(|py| {
<span class="kw">let </span>array = PyArray1::arange(py, <span class="number">0</span>, <span class="number">10</span>, <span class="number">1</span>);
<span class="macro">assert!</span>(array.is_contiguous());
<span class="kw">let </span>view = py
.eval(<span class="string">"array[::2]"</span>, <span class="prelude-val">None</span>, <span class="prelude-val">Some</span>([(<span class="string">"array"</span>, array)].into_py_dict(py)))
.unwrap()
.downcast::<PyArray1<i32>>()
.unwrap();
<span class="macro">assert!</span>(!view.is_contiguous());
});</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.is_fortran_contiguous" class="method"><a class="src rightside" href="../../src/numpy/untyped_array.rs.html#146-148">source</a><h4 class="code-header">pub fn <a href="#method.is_fortran_contiguous" class="fn">is_fortran_contiguous</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.bool.html">bool</a></h4></section></summary><div class="docblock"><p>Returns <code>true</code> if the internal data of the array is Fortran-style/column-major contiguous.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.is_c_contiguous" class="method"><a class="src rightside" href="../../src/numpy/untyped_array.rs.html#152-154">source</a><h4 class="code-header">pub fn <a href="#method.is_c_contiguous" class="fn">is_c_contiguous</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.bool.html">bool</a></h4></section></summary><div class="docblock"><p>Returns <code>true</code> if the internal data of the array is C-style/row-major contiguous.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.ndim" class="method"><a class="src rightside" href="../../src/numpy/untyped_array.rs.html#176-178">source</a><h4 class="code-header">pub fn <a href="#method.ndim" class="fn">ndim</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.usize.html">usize</a></h4></section></summary><div class="docblock"><p>Returns the number of dimensions of the array.</p>
<p>See also <a href="https://numpy.org/doc/stable/reference/generated/numpy.ndarray.ndim.html"><code>ndarray.ndim</code></a> and <a href="https://numpy.org/doc/stable/reference/c-api/array.html#c.PyArray_NDIM"><code>PyArray_NDIM</code></a>.</p>
<h5 id="example-13"><a href="#example-13">Example</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>numpy::PyArray3;
<span class="kw">use </span>pyo3::Python;
Python::with_gil(|py| {
<span class="kw">let </span>arr = PyArray3::<f64>::zeros(py, [<span class="number">4</span>, <span class="number">5</span>, <span class="number">6</span>], <span class="bool-val">false</span>);
<span class="macro">assert_eq!</span>(arr.ndim(), <span class="number">3</span>);
});</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.strides" class="method"><a class="src rightside" href="../../src/numpy/untyped_array.rs.html#199-210">source</a><h4 class="code-header">pub fn <a href="#method.strides" class="fn">strides</a>(&self) -> &[<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.isize.html">isize</a>]</h4></section></summary><div class="docblock"><p>Returns a slice indicating how many bytes to advance when iterating along each axis.</p>
<p>See also <a href="https://numpy.org/doc/stable/reference/generated/numpy.ndarray.strides.html"><code>ndarray.strides</code></a> and <a href="https://numpy.org/doc/stable/reference/c-api/array.html#c.PyArray_STRIDES"><code>PyArray_STRIDES</code></a>.</p>
<h5 id="example-14"><a href="#example-14">Example</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>numpy::PyArray3;
<span class="kw">use </span>pyo3::Python;
Python::with_gil(|py| {
<span class="kw">let </span>arr = PyArray3::<f64>::zeros(py, [<span class="number">4</span>, <span class="number">5</span>, <span class="number">6</span>], <span class="bool-val">false</span>);
<span class="macro">assert_eq!</span>(arr.strides(), <span class="kw-2">&</span>[<span class="number">240</span>, <span class="number">48</span>, <span class="number">8</span>]);
});</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.shape" class="method"><a class="src rightside" href="../../src/numpy/untyped_array.rs.html#232-243">source</a><h4 class="code-header">pub fn <a href="#method.shape" class="fn">shape</a>(&self) -> &[<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.usize.html">usize</a>]</h4></section></summary><div class="docblock"><p>Returns a slice which contains dimmensions of the array.</p>
<p>See also [<code>ndarray.shape</code>][ndaray-shape] and <a href="https://numpy.org/doc/stable/reference/c-api/array.html#c.PyArray_DIMS"><code>PyArray_DIMS</code></a>.</p>
<h5 id="example-15"><a href="#example-15">Example</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>numpy::PyArray3;
<span class="kw">use </span>pyo3::Python;
Python::with_gil(|py| {
<span class="kw">let </span>arr = PyArray3::<f64>::zeros(py, [<span class="number">4</span>, <span class="number">5</span>, <span class="number">6</span>], <span class="bool-val">false</span>);
<span class="macro">assert_eq!</span>(arr.shape(), <span class="kw-2">&</span>[<span class="number">4</span>, <span class="number">5</span>, <span class="number">6</span>]);
});</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.len" class="method"><a class="src rightside" href="../../src/numpy/untyped_array.rs.html#247-249">source</a><h4 class="code-header">pub fn <a href="#method.len" class="fn">len</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.usize.html">usize</a></h4></section></summary><div class="docblock"><p>Calculates the total number of elements in the array.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.is_empty" class="method"><a class="src rightside" href="../../src/numpy/untyped_array.rs.html#253-255">source</a><h4 class="code-header">pub fn <a href="#method.is_empty" class="fn">is_empty</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.bool.html">bool</a></h4></section></summary><div class="docblock"><p>Returns <code>true</code> if the there are no elements in the array.</p>
</div></details></div><h2 id="deref-methods-PyAny" class="section-header"><span>Methods from <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/ops/deref/trait.Deref.html" title="trait core::ops::deref::Deref">Deref</a><Target = PyAny></span><a href="#deref-methods-PyAny" class="anchor">§</a></h2><div id="deref-methods-PyAny-1" class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.is" class="method"><h4 class="code-header">pub fn <a href="#method.is" class="fn">is</a><T>(&self, other: <a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.reference.html">&T</a>) -> <a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.bool.html">bool</a><div class="where">where
T: AsPyPointer,</div></h4></section></summary><div class="docblock"><p>Returns whether <code>self</code> and <code>other</code> point to the same object. To compare
the equality of two objects (the <code>==</code> operator), use <a href="PyAny::eq"><code>eq</code></a>.</p>
<p>This is equivalent to the Python expression <code>self is other</code>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.hasattr" class="method"><h4 class="code-header">pub fn <a href="#method.hasattr" class="fn">hasattr</a><N>(&self, attr_name: N) -> <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.bool.html">bool</a>, PyErr><div class="where">where
N: IntoPy<Py<PyString>>,</div></h4></section></summary><div class="docblock"><p>Determines whether this object has the given attribute.</p>
<p>This is equivalent to the Python expression <code>hasattr(self, attr_name)</code>.</p>
<p>To avoid repeated temporary allocations of Python strings, the [<code>intern!</code>] macro can be used
to intern <code>attr_name</code>.</p>
<h5 id="example-interning-the-attribute-name"><a href="#example-interning-the-attribute-name">Example: <code>intern!</code>ing the attribute name</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="attr">#[pyfunction]
</span><span class="kw">fn </span>has_version(sys: <span class="kw-2">&</span>Bound<<span class="lifetime">'_</span>, PyModule>) -> PyResult<bool> {
sys.hasattr(<span class="macro">intern!</span>(sys.py(), <span class="string">"version"</span>))
}</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.getattr" class="method"><h4 class="code-header">pub fn <a href="#method.getattr" class="fn">getattr</a><N>(&self, attr_name: N) -> <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><&PyAny, PyErr><div class="where">where
N: IntoPy<Py<PyString>>,</div></h4></section></summary><div class="docblock"><p>Retrieves an attribute value.</p>
<p>This is equivalent to the Python expression <code>self.attr_name</code>.</p>
<p>To avoid repeated temporary allocations of Python strings, the [<code>intern!</code>] macro can be used
to intern <code>attr_name</code>.</p>
<h5 id="example-interning-the-attribute-name-1"><a href="#example-interning-the-attribute-name-1">Example: <code>intern!</code>ing the attribute name</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="attr">#[pyfunction]
</span><span class="kw">fn </span>version<<span class="lifetime">'py</span>>(sys: <span class="kw-2">&</span>Bound<<span class="lifetime">'py</span>, PyModule>) -> PyResult<Bound<<span class="lifetime">'py</span>, PyAny>> {
sys.getattr(<span class="macro">intern!</span>(sys.py(), <span class="string">"version"</span>))
}</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.setattr" class="method"><h4 class="code-header">pub fn <a href="#method.setattr" class="fn">setattr</a><N, V>(&self, attr_name: N, value: V) -> <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.unit.html">()</a>, PyErr><div class="where">where
N: IntoPy<Py<PyString>>,
V: ToPyObject,</div></h4></section></summary><div class="docblock"><p>Sets an attribute value.</p>
<p>This is equivalent to the Python expression <code>self.attr_name = value</code>.</p>
<p>To avoid repeated temporary allocations of Python strings, the [<code>intern!</code>] macro can be used
to intern <code>name</code>.</p>
<h5 id="example-interning-the-attribute-name-2"><a href="#example-interning-the-attribute-name-2">Example: <code>intern!</code>ing the attribute name</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="attr">#[pyfunction]
</span><span class="kw">fn </span>set_answer(ob: <span class="kw-2">&</span>Bound<<span class="lifetime">'_</span>, PyAny>) -> PyResult<()> {
ob.setattr(<span class="macro">intern!</span>(ob.py(), <span class="string">"answer"</span>), <span class="number">42</span>)
}</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.delattr" class="method"><h4 class="code-header">pub fn <a href="#method.delattr" class="fn">delattr</a><N>(&self, attr_name: N) -> <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.unit.html">()</a>, PyErr><div class="where">where
N: IntoPy<Py<PyString>>,</div></h4></section></summary><div class="docblock"><p>Deletes an attribute.</p>
<p>This is equivalent to the Python statement <code>del self.attr_name</code>.</p>
<p>To avoid repeated temporary allocations of Python strings, the [<code>intern!</code>] macro can be used
to intern <code>attr_name</code>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.compare" class="method"><h4 class="code-header">pub fn <a href="#method.compare" class="fn">compare</a><O>(&self, other: O) -> <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="enum" href="https://doc.rust-lang.org/1.76.0/core/cmp/enum.Ordering.html" title="enum core::cmp::Ordering">Ordering</a>, PyErr><div class="where">where
O: ToPyObject,</div></h4></section></summary><div class="docblock"><p>Returns an <a href="https://doc.rust-lang.org/1.76.0/core/cmp/enum.Ordering.html" title="enum core::cmp::Ordering"><code>Ordering</code></a> between <code>self</code> and <code>other</code>.</p>
<p>This is equivalent to the following Python code:</p>
<div class="example-wrap"><pre class="language-python"><code>if self == other:
return Equal
elif a < b:
return Less
elif a > b:
return Greater
else:
raise TypeError("PyAny::compare(): All comparisons returned false")
</code></pre></div><h5 id="examples"><a href="#examples">Examples</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>pyo3::prelude::<span class="kw-2">*</span>;
<span class="kw">use </span>pyo3::types::PyFloat;
<span class="kw">use </span>std::cmp::Ordering;
Python::with_gil(|py| -> PyResult<()> {
<span class="kw">let </span>a = PyFloat::new_bound(py, <span class="number">0_f64</span>);
<span class="kw">let </span>b = PyFloat::new_bound(py, <span class="number">42_f64</span>);
<span class="macro">assert_eq!</span>(a.compare(b)<span class="question-mark">?</span>, Ordering::Less);
<span class="prelude-val">Ok</span>(())
})<span class="question-mark">?</span>;</code></pre></div>
<p>It will return <code>PyErr</code> for values that cannot be compared:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>pyo3::prelude::<span class="kw-2">*</span>;
<span class="kw">use </span>pyo3::types::{PyFloat, PyString};
Python::with_gil(|py| -> PyResult<()> {
<span class="kw">let </span>a = PyFloat::new_bound(py, <span class="number">0_f64</span>);
<span class="kw">let </span>b = PyString::new_bound(py, <span class="string">"zero"</span>);
<span class="macro">assert!</span>(a.compare(b).is_err());
<span class="prelude-val">Ok</span>(())
})<span class="question-mark">?</span>;</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.rich_compare" class="method"><h4 class="code-header">pub fn <a href="#method.rich_compare" class="fn">rich_compare</a><O>(
&self,
other: O,
compare_op: CompareOp
) -> <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><&PyAny, PyErr><div class="where">where
O: ToPyObject,</div></h4></section></summary><div class="docblock"><p>Tests whether two Python objects obey a given [<code>CompareOp</code>].</p>
<p><a href="Self::lt"><code>lt</code></a>, <a href="Self::le"><code>le</code></a>, <a href="Self::eq"><code>eq</code></a>, <a href="Self::ne"><code>ne</code></a>,
<a href="Self::gt"><code>gt</code></a> and <a href="Self::ge"><code>ge</code></a> are the specialized versions
of this function.</p>
<p>Depending on the value of <code>compare_op</code>, this is equivalent to one of the
following Python expressions:</p>
<div><table><thead><tr><th style="text-align: center"><code>compare_op</code></th><th style="text-align: center">Python expression</th></tr></thead><tbody>
<tr><td style="text-align: center">[<code>CompareOp::Eq</code>]</td><td style="text-align: center"><code>self == other</code></td></tr>
<tr><td style="text-align: center">[<code>CompareOp::Ne</code>]</td><td style="text-align: center"><code>self != other</code></td></tr>
<tr><td style="text-align: center">[<code>CompareOp::Lt</code>]</td><td style="text-align: center"><code>self < other</code></td></tr>
<tr><td style="text-align: center">[<code>CompareOp::Le</code>]</td><td style="text-align: center"><code>self <= other</code></td></tr>
<tr><td style="text-align: center">[<code>CompareOp::Gt</code>]</td><td style="text-align: center"><code>self > other</code></td></tr>
<tr><td style="text-align: center">[<code>CompareOp::Ge</code>]</td><td style="text-align: center"><code>self >= other</code></td></tr>
</tbody></table>
</div><h5 id="examples-1"><a href="#examples-1">Examples</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>pyo3::class::basic::CompareOp;
<span class="kw">use </span>pyo3::prelude::<span class="kw-2">*</span>;
<span class="kw">use </span>pyo3::types::PyInt;
Python::with_gil(|py| -> PyResult<()> {
<span class="kw">let </span>a: Bound<<span class="lifetime">'_</span>, PyInt> = <span class="number">0_u8</span>.into_py(py).into_bound(py).downcast_into()<span class="question-mark">?</span>;
<span class="kw">let </span>b: Bound<<span class="lifetime">'_</span>, PyInt> = <span class="number">42_u8</span>.into_py(py).into_bound(py).downcast_into()<span class="question-mark">?</span>;
<span class="macro">assert!</span>(a.rich_compare(b, CompareOp::Le)<span class="question-mark">?</span>.is_truthy()<span class="question-mark">?</span>);
<span class="prelude-val">Ok</span>(())
})<span class="question-mark">?</span>;</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.lt" class="method"><h4 class="code-header">pub fn <a href="#method.lt" class="fn">lt</a><O>(&self, other: O) -> <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.bool.html">bool</a>, PyErr><div class="where">where
O: ToPyObject,</div></h4></section></summary><div class="docblock"><p>Tests whether this object is less than another.</p>
<p>This is equivalent to the Python expression <code>self < other</code>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.le" class="method"><h4 class="code-header">pub fn <a href="#method.le" class="fn">le</a><O>(&self, other: O) -> <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.bool.html">bool</a>, PyErr><div class="where">where
O: ToPyObject,</div></h4></section></summary><div class="docblock"><p>Tests whether this object is less than or equal to another.</p>
<p>This is equivalent to the Python expression <code>self <= other</code>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.eq" class="method"><h4 class="code-header">pub fn <a href="#method.eq" class="fn">eq</a><O>(&self, other: O) -> <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.bool.html">bool</a>, PyErr><div class="where">where
O: ToPyObject,</div></h4></section></summary><div class="docblock"><p>Tests whether this object is equal to another.</p>
<p>This is equivalent to the Python expression <code>self == other</code>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.ne" class="method"><h4 class="code-header">pub fn <a href="#method.ne" class="fn">ne</a><O>(&self, other: O) -> <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.bool.html">bool</a>, PyErr><div class="where">where
O: ToPyObject,</div></h4></section></summary><div class="docblock"><p>Tests whether this object is not equal to another.</p>
<p>This is equivalent to the Python expression <code>self != other</code>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.gt" class="method"><h4 class="code-header">pub fn <a href="#method.gt" class="fn">gt</a><O>(&self, other: O) -> <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.bool.html">bool</a>, PyErr><div class="where">where
O: ToPyObject,</div></h4></section></summary><div class="docblock"><p>Tests whether this object is greater than another.</p>
<p>This is equivalent to the Python expression <code>self > other</code>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.ge" class="method"><h4 class="code-header">pub fn <a href="#method.ge" class="fn">ge</a><O>(&self, other: O) -> <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.bool.html">bool</a>, PyErr><div class="where">where
O: ToPyObject,</div></h4></section></summary><div class="docblock"><p>Tests whether this object is greater than or equal to another.</p>
<p>This is equivalent to the Python expression <code>self >= other</code>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.is_callable" class="method"><h4 class="code-header">pub fn <a href="#method.is_callable" class="fn">is_callable</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.bool.html">bool</a></h4></section></summary><div class="docblock"><p>Determines whether this object appears callable.</p>
<p>This is equivalent to Python’s <a href="https://docs.python.org/3/library/functions.html#callable"><code>callable()</code></a> function.</p>
<h5 id="examples-2"><a href="#examples-2">Examples</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>pyo3::prelude::<span class="kw-2">*</span>;
Python::with_gil(|py| -> PyResult<()> {
<span class="kw">let </span>builtins = PyModule::import_bound(py, <span class="string">"builtins"</span>)<span class="question-mark">?</span>;
<span class="kw">let </span>print = builtins.getattr(<span class="string">"print"</span>)<span class="question-mark">?</span>;
<span class="macro">assert!</span>(print.is_callable());
<span class="prelude-val">Ok</span>(())
})<span class="question-mark">?</span>;</code></pre></div>
<p>This is equivalent to the Python statement <code>assert callable(print)</code>.</p>
<p>Note that unless an API needs to distinguish between callable and
non-callable objects, there is no point in checking for callability.
Instead, it is better to just do the call and handle potential
exceptions.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.call" class="method"><h4 class="code-header">pub fn <a href="#method.call" class="fn">call</a>(
&self,
args: impl IntoPy<Py<PyTuple>>,
kwargs: <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a><&PyDict>
) -> <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><&PyAny, PyErr></h4></section></summary><div class="docblock"><p>Calls the object.</p>
<p>This is equivalent to the Python expression <code>self(*args, **kwargs)</code>.</p>
<h5 id="examples-3"><a href="#examples-3">Examples</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>pyo3::prelude::<span class="kw-2">*</span>;
<span class="kw">use </span>pyo3::types::PyDict;
<span class="kw">const </span>CODE: <span class="kw-2">&</span>str = <span class="string">r#"
def function(*args, **kwargs):
assert args == ("hello",)
assert kwargs == {"cruel": "world"}
return "called with args and kwargs"
"#</span>;
Python::with_gil(|py| {
<span class="kw">let </span>module = PyModule::from_code_bound(py, CODE, <span class="string">""</span>, <span class="string">""</span>)<span class="question-mark">?</span>;
<span class="kw">let </span>fun = module.getattr(<span class="string">"function"</span>)<span class="question-mark">?</span>;
<span class="kw">let </span>args = (<span class="string">"hello"</span>,);
<span class="kw">let </span>kwargs = PyDict::new_bound(py);
kwargs.set_item(<span class="string">"cruel"</span>, <span class="string">"world"</span>)<span class="question-mark">?</span>;
<span class="kw">let </span>result = fun.call(args, <span class="prelude-val">Some</span>(<span class="kw-2">&</span>kwargs))<span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(result.extract::<String>()<span class="question-mark">?</span>, <span class="string">"called with args and kwargs"</span>);
<span class="prelude-val">Ok</span>(())
})</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.call0" class="method"><h4 class="code-header">pub fn <a href="#method.call0" class="fn">call0</a>(&self) -> <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><&PyAny, PyErr></h4></section></summary><div class="docblock"><p>Calls the object without arguments.</p>
<p>This is equivalent to the Python expression <code>self()</code>.</p>
<h5 id="examples-4"><a href="#examples-4">Examples</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>pyo3::prelude::<span class="kw-2">*</span>;
Python::with_gil(|py| -> PyResult<()> {
<span class="kw">let </span>module = PyModule::import_bound(py, <span class="string">"builtins"</span>)<span class="question-mark">?</span>;
<span class="kw">let </span>help = module.getattr(<span class="string">"help"</span>)<span class="question-mark">?</span>;
help.call0()<span class="question-mark">?</span>;
<span class="prelude-val">Ok</span>(())
})<span class="question-mark">?</span>;</code></pre></div>
<p>This is equivalent to the Python expression <code>help()</code>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.call1" class="method"><h4 class="code-header">pub fn <a href="#method.call1" class="fn">call1</a>(&self, args: impl IntoPy<Py<PyTuple>>) -> <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><&PyAny, PyErr></h4></section></summary><div class="docblock"><p>Calls the object with only positional arguments.</p>
<p>This is equivalent to the Python expression <code>self(*args)</code>.</p>
<h5 id="examples-5"><a href="#examples-5">Examples</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>pyo3::prelude::<span class="kw-2">*</span>;
<span class="kw">const </span>CODE: <span class="kw-2">&</span>str = <span class="string">r#"
def function(*args, **kwargs):
assert args == ("hello",)
assert kwargs == {}
return "called with args"
"#</span>;
Python::with_gil(|py| {
<span class="kw">let </span>module = PyModule::from_code_bound(py, CODE, <span class="string">""</span>, <span class="string">""</span>)<span class="question-mark">?</span>;
<span class="kw">let </span>fun = module.getattr(<span class="string">"function"</span>)<span class="question-mark">?</span>;
<span class="kw">let </span>args = (<span class="string">"hello"</span>,);
<span class="kw">let </span>result = fun.call1(args)<span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(result.extract::<String>()<span class="question-mark">?</span>, <span class="string">"called with args"</span>);
<span class="prelude-val">Ok</span>(())
})</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.call_method" class="method"><h4 class="code-header">pub fn <a href="#method.call_method" class="fn">call_method</a><N, A>(
&self,
name: N,
args: A,
kwargs: <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a><&PyDict>
) -> <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><&PyAny, PyErr><div class="where">where
N: IntoPy<Py<PyString>>,
A: IntoPy<Py<PyTuple>>,</div></h4></section></summary><div class="docblock"><p>Calls a method on the object.</p>
<p>This is equivalent to the Python expression <code>self.name(*args, **kwargs)</code>.</p>
<p>To avoid repeated temporary allocations of Python strings, the [<code>intern!</code>] macro can be used
to intern <code>name</code>.</p>
<h5 id="examples-6"><a href="#examples-6">Examples</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>pyo3::prelude::<span class="kw-2">*</span>;
<span class="kw">use </span>pyo3::types::PyDict;
<span class="kw">const </span>CODE: <span class="kw-2">&</span>str = <span class="string">r#"
class A:
def method(self, *args, **kwargs):
assert args == ("hello",)
assert kwargs == {"cruel": "world"}
return "called with args and kwargs"
a = A()
"#</span>;
Python::with_gil(|py| {
<span class="kw">let </span>module = PyModule::from_code_bound(py, CODE, <span class="string">""</span>, <span class="string">""</span>)<span class="question-mark">?</span>;
<span class="kw">let </span>instance = module.getattr(<span class="string">"a"</span>)<span class="question-mark">?</span>;
<span class="kw">let </span>args = (<span class="string">"hello"</span>,);
<span class="kw">let </span>kwargs = PyDict::new_bound(py);
kwargs.set_item(<span class="string">"cruel"</span>, <span class="string">"world"</span>)<span class="question-mark">?</span>;
<span class="kw">let </span>result = instance.call_method(<span class="string">"method"</span>, args, <span class="prelude-val">Some</span>(<span class="kw-2">&</span>kwargs))<span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(result.extract::<String>()<span class="question-mark">?</span>, <span class="string">"called with args and kwargs"</span>);
<span class="prelude-val">Ok</span>(())
})</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.call_method0" class="method"><h4 class="code-header">pub fn <a href="#method.call_method0" class="fn">call_method0</a><N>(&self, name: N) -> <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><&PyAny, PyErr><div class="where">where
N: IntoPy<Py<PyString>>,</div></h4></section></summary><div class="docblock"><p>Calls a method on the object without arguments.</p>
<p>This is equivalent to the Python expression <code>self.name()</code>.</p>
<p>To avoid repeated temporary allocations of Python strings, the [<code>intern!</code>] macro can be used
to intern <code>name</code>.</p>
<h5 id="examples-7"><a href="#examples-7">Examples</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>pyo3::prelude::<span class="kw-2">*</span>;
<span class="kw">const </span>CODE: <span class="kw-2">&</span>str = <span class="string">r#"
class A:
def method(self, *args, **kwargs):
assert args == ()
assert kwargs == {}
return "called with no arguments"
a = A()
"#</span>;
Python::with_gil(|py| {
<span class="kw">let </span>module = PyModule::from_code_bound(py, CODE, <span class="string">""</span>, <span class="string">""</span>)<span class="question-mark">?</span>;
<span class="kw">let </span>instance = module.getattr(<span class="string">"a"</span>)<span class="question-mark">?</span>;
<span class="kw">let </span>result = instance.call_method0(<span class="string">"method"</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(result.extract::<String>()<span class="question-mark">?</span>, <span class="string">"called with no arguments"</span>);
<span class="prelude-val">Ok</span>(())
})</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.call_method1" class="method"><h4 class="code-header">pub fn <a href="#method.call_method1" class="fn">call_method1</a><N, A>(&self, name: N, args: A) -> <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><&PyAny, PyErr><div class="where">where
N: IntoPy<Py<PyString>>,
A: IntoPy<Py<PyTuple>>,</div></h4></section></summary><div class="docblock"><p>Calls a method on the object with only positional arguments.</p>
<p>This is equivalent to the Python expression <code>self.name(*args)</code>.</p>
<p>To avoid repeated temporary allocations of Python strings, the [<code>intern!</code>] macro can be used
to intern <code>name</code>.</p>
<h5 id="examples-8"><a href="#examples-8">Examples</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>pyo3::prelude::<span class="kw-2">*</span>;
<span class="kw">const </span>CODE: <span class="kw-2">&</span>str = <span class="string">r#"
class A:
def method(self, *args, **kwargs):
assert args == ("hello",)
assert kwargs == {}
return "called with args"
a = A()
"#</span>;
Python::with_gil(|py| {
<span class="kw">let </span>module = PyModule::from_code_bound(py, CODE, <span class="string">""</span>, <span class="string">""</span>)<span class="question-mark">?</span>;
<span class="kw">let </span>instance = module.getattr(<span class="string">"a"</span>)<span class="question-mark">?</span>;
<span class="kw">let </span>args = (<span class="string">"hello"</span>,);
<span class="kw">let </span>result = instance.call_method1(<span class="string">"method"</span>, args)<span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(result.extract::<String>()<span class="question-mark">?</span>, <span class="string">"called with args"</span>);
<span class="prelude-val">Ok</span>(())
})</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.is_true" class="method"><h4 class="code-header">pub fn <a href="#method.is_true" class="fn">is_true</a>(&self) -> <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.bool.html">bool</a>, PyErr></h4></section><span class="item-info"><div class="stab deprecated"><span class="emoji">👎</span><span>Deprecated since 0.21.0: use <code>.is_truthy()</code> instead</span></div></span></summary><div class="docblock"><p>Returns whether the object is considered to be true.</p>
<p>This is equivalent to the Python expression <code>bool(self)</code>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.is_truthy" class="method"><h4 class="code-header">pub fn <a href="#method.is_truthy" class="fn">is_truthy</a>(&self) -> <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.bool.html">bool</a>, PyErr></h4></section></summary><div class="docblock"><p>Returns whether the object is considered to be true.</p>
<p>This applies truth value testing equivalent to the Python expression <code>bool(self)</code>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.is_none" class="method"><h4 class="code-header">pub fn <a href="#method.is_none" class="fn">is_none</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.bool.html">bool</a></h4></section></summary><div class="docblock"><p>Returns whether the object is considered to be None.</p>
<p>This is equivalent to the Python expression <code>self is None</code>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.is_ellipsis" class="method"><h4 class="code-header">pub fn <a href="#method.is_ellipsis" class="fn">is_ellipsis</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.bool.html">bool</a></h4></section><span class="item-info"><div class="stab deprecated"><span class="emoji">👎</span><span>Deprecated since 0.20.0: use <code>.is(py.Ellipsis())</code> instead</span></div></span></summary><div class="docblock"><p>Returns whether the object is Ellipsis, e.g. <code>...</code>.</p>
<p>This is equivalent to the Python expression <code>self is ...</code>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.is_empty-1" class="method"><h4 class="code-header">pub fn <a href="#method.is_empty-1" class="fn">is_empty</a>(&self) -> <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.bool.html">bool</a>, PyErr></h4></section></summary><div class="docblock"><p>Returns true if the sequence or mapping has a length of 0.</p>
<p>This is equivalent to the Python expression <code>len(self) == 0</code>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.get_item" class="method"><h4 class="code-header">pub fn <a href="#method.get_item" class="fn">get_item</a><K>(&self, key: K) -> <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><&PyAny, PyErr><div class="where">where
K: ToPyObject,</div></h4></section></summary><div class="docblock"><p>Gets an item from the collection.</p>
<p>This is equivalent to the Python expression <code>self[key]</code>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.set_item" class="method"><h4 class="code-header">pub fn <a href="#method.set_item" class="fn">set_item</a><K, V>(&self, key: K, value: V) -> <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.unit.html">()</a>, PyErr><div class="where">where
K: ToPyObject,
V: ToPyObject,</div></h4></section></summary><div class="docblock"><p>Sets a collection item value.</p>
<p>This is equivalent to the Python expression <code>self[key] = value</code>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.del_item" class="method"><h4 class="code-header">pub fn <a href="#method.del_item" class="fn">del_item</a><K>(&self, key: K) -> <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.unit.html">()</a>, PyErr><div class="where">where
K: ToPyObject,</div></h4></section></summary><div class="docblock"><p>Deletes an item from the collection.</p>
<p>This is equivalent to the Python expression <code>del self[key]</code>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.iter" class="method"><h4 class="code-header">pub fn <a href="#method.iter" class="fn">iter</a>(&self) -> <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><&PyIterator, PyErr></h4></section></summary><div class="docblock"><p>Takes an object and returns an iterator for it.</p>
<p>This is typically a new iterator but if the argument is an iterator,
this returns itself.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.get_type" class="method"><h4 class="code-header">pub fn <a href="#method.get_type" class="fn">get_type</a>(&self) -> &PyType</h4></section></summary><div class="docblock"><p>Returns the Python type object for this object’s type.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.get_type_ptr" class="method"><h4 class="code-header">pub fn <a href="#method.get_type_ptr" class="fn">get_type_ptr</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.pointer.html">*mut </a>PyTypeObject</h4></section></summary><div class="docblock"><p>Returns the Python type pointer for this object.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.downcast" class="method"><h4 class="code-header">pub fn <a href="#method.downcast" class="fn">downcast</a><T>(&self) -> <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.reference.html">&T</a>, PyDowncastError<'_>><div class="where">where
T: PyTypeCheck<AsRefTarget = T>,</div></h4></section></summary><div class="docblock"><p>Downcast this <code>PyAny</code> to a concrete Python type or pyclass.</p>
<p>Note that you can often avoid downcasting yourself by just specifying
the desired type in function or method signatures.
However, manual downcasting is sometimes necessary.</p>
<p>For extracting a Rust-only type, see <a href="struct.PyAny.html#method.extract"><code>PyAny::extract</code></a>.</p>
<h5 id="example-downcasting-to-a-specific-python-object"><a href="#example-downcasting-to-a-specific-python-object">Example: Downcasting to a specific Python object</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>pyo3::prelude::<span class="kw-2">*</span>;
<span class="kw">use </span>pyo3::types::{PyDict, PyList};
Python::with_gil(|py| {
<span class="kw">let </span>dict = PyDict::new_bound(py);
<span class="macro">assert!</span>(dict.is_instance_of::<PyAny>());
<span class="kw">let </span>any = dict.as_any();
<span class="macro">assert!</span>(any.downcast::<PyDict>().is_ok());
<span class="macro">assert!</span>(any.downcast::<PyList>().is_err());
});</code></pre></div>
<h5 id="example-getting-a-reference-to-a-pyclass"><a href="#example-getting-a-reference-to-a-pyclass">Example: Getting a reference to a pyclass</a></h5>
<p>This is useful if you want to mutate a <code>PyObject</code> that
might actually be a pyclass.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>pyo3::prelude::<span class="kw-2">*</span>;
<span class="attr">#[pyclass]
</span><span class="kw">struct </span>Class {
i: i32,
}
Python::with_gil(|py| {
<span class="kw">let </span>class = Py::new(py, Class { i: <span class="number">0 </span>}).unwrap().into_bound(py).into_any();
<span class="kw">let </span>class_bound: <span class="kw-2">&</span>Bound<<span class="lifetime">'_</span>, Class> = class.downcast()<span class="question-mark">?</span>;
class_bound.borrow_mut().i += <span class="number">1</span>;
<span class="comment">// Alternatively you can get a `PyRefMut` directly
</span><span class="kw">let </span>class_ref: PyRefMut<<span class="lifetime">'_</span>, Class> = class.extract()<span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(class_ref.i, <span class="number">1</span>);
<span class="prelude-val">Ok</span>(())
})</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.downcast_exact" class="method"><h4 class="code-header">pub fn <a href="#method.downcast_exact" class="fn">downcast_exact</a><T>(&self) -> <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.reference.html">&T</a>, PyDowncastError<'_>><div class="where">where
T: PyTypeInfo<AsRefTarget = T>,</div></h4></section></summary><div class="docblock"><p>Downcast this <code>PyAny</code> to a concrete Python type or pyclass (but not a subclass of it).</p>
<p>It is almost always better to use [<code>PyAny::downcast</code>] because it accounts for Python
subtyping. Use this method only when you do not want to allow subtypes.</p>
<p>The advantage of this method over [<code>PyAny::downcast</code>] is that it is faster. The implementation
of <code>downcast_exact</code> uses the equivalent of the Python expression <code>type(self) is T</code>, whereas
<code>downcast</code> uses <code>isinstance(self, T)</code>.</p>
<p>For extracting a Rust-only type, see <a href="struct.PyAny.html#method.extract"><code>PyAny::extract</code></a>.</p>
<h5 id="example-downcasting-to-a-specific-python-object-but-not-a-subtype"><a href="#example-downcasting-to-a-specific-python-object-but-not-a-subtype">Example: Downcasting to a specific Python object but not a subtype</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>pyo3::prelude::<span class="kw-2">*</span>;
<span class="kw">use </span>pyo3::types::{PyBool, PyLong};
Python::with_gil(|py| {
<span class="kw">let </span>b = PyBool::new_bound(py, <span class="bool-val">true</span>);
<span class="macro">assert!</span>(b.is_instance_of::<PyBool>());
<span class="kw">let </span>any: <span class="kw-2">&</span>Bound<<span class="lifetime">'_</span>, PyAny> = b.as_any();
<span class="comment">// `bool` is a subtype of `int`, so `downcast` will accept a `bool` as an `int`
// but `downcast_exact` will not.
</span><span class="macro">assert!</span>(any.downcast::<PyLong>().is_ok());
<span class="macro">assert!</span>(any.downcast_exact::<PyLong>().is_err());
<span class="macro">assert!</span>(any.downcast_exact::<PyBool>().is_ok());
});</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.downcast_unchecked" class="method"><h4 class="code-header">pub unsafe fn <a href="#method.downcast_unchecked" class="fn">downcast_unchecked</a><T>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.reference.html">&T</a><div class="where">where
T: HasPyGilRef<AsRefTarget = T>,</div></h4></section></summary><div class="docblock"><p>Converts this <code>PyAny</code> to a concrete Python type without checking validity.</p>
<h5 id="safety-12"><a href="#safety-12">Safety</a></h5>
<p>Callers must ensure that the type is valid or risk type confusion.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.extract" class="method"><h4 class="code-header">pub fn <a href="#method.extract" class="fn">extract</a><'py, D>(&'py self) -> <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><D, PyErr><div class="where">where
D: FromPyObject<'py>,</div></h4></section></summary><div class="docblock"><p>Extracts some type from the Python object.</p>
<p>This is a wrapper function around [<code>FromPyObject::extract()</code>].</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.get_refcnt" class="method"><h4 class="code-header">pub fn <a href="#method.get_refcnt" class="fn">get_refcnt</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.isize.html">isize</a></h4></section></summary><div class="docblock"><p>Returns the reference count for the Python object.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.repr" class="method"><h4 class="code-header">pub fn <a href="#method.repr" class="fn">repr</a>(&self) -> <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><&PyString, PyErr></h4></section></summary><div class="docblock"><p>Computes the “repr” representation of self.</p>
<p>This is equivalent to the Python expression <code>repr(self)</code>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.str" class="method"><h4 class="code-header">pub fn <a href="#method.str" class="fn">str</a>(&self) -> <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><&PyString, PyErr></h4></section></summary><div class="docblock"><p>Computes the “str” representation of self.</p>
<p>This is equivalent to the Python expression <code>str(self)</code>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.hash" class="method"><h4 class="code-header">pub fn <a href="#method.hash" class="fn">hash</a>(&self) -> <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.isize.html">isize</a>, PyErr></h4></section></summary><div class="docblock"><p>Retrieves the hash code of self.</p>
<p>This is equivalent to the Python expression <code>hash(self)</code>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.len-1" class="method"><h4 class="code-header">pub fn <a href="#method.len-1" class="fn">len</a>(&self) -> <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.usize.html">usize</a>, PyErr></h4></section></summary><div class="docblock"><p>Returns the length of the sequence or mapping.</p>
<p>This is equivalent to the Python expression <code>len(self)</code>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.dir" class="method"><h4 class="code-header">pub fn <a href="#method.dir" class="fn">dir</a>(&self) -> &PyList</h4></section></summary><div class="docblock"><p>Returns the list of attributes of this object.</p>
<p>This is equivalent to the Python expression <code>dir(self)</code>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.is_instance" class="method"><h4 class="code-header">pub fn <a href="#method.is_instance" class="fn">is_instance</a>(&self, ty: &PyAny) -> <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.bool.html">bool</a>, PyErr></h4></section></summary><div class="docblock"><p>Checks whether this object is an instance of type <code>ty</code>.</p>
<p>This is equivalent to the Python expression <code>isinstance(self, ty)</code>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.is_exact_instance" class="method"><h4 class="code-header">pub fn <a href="#method.is_exact_instance" class="fn">is_exact_instance</a>(&self, ty: &PyAny) -> <a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.bool.html">bool</a></h4></section></summary><div class="docblock"><p>Checks whether this object is an instance of exactly type <code>ty</code> (not a subclass).</p>
<p>This is equivalent to the Python expression <code>type(self) is ty</code>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.is_instance_of" class="method"><h4 class="code-header">pub fn <a href="#method.is_instance_of" class="fn">is_instance_of</a><T>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.bool.html">bool</a><div class="where">where
T: PyTypeInfo,</div></h4></section></summary><div class="docblock"><p>Checks whether this object is an instance of type <code>T</code>.</p>
<p>This is equivalent to the Python expression <code>isinstance(self, T)</code>,
if the type <code>T</code> is known at compile time.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.is_exact_instance_of" class="method"><h4 class="code-header">pub fn <a href="#method.is_exact_instance_of" class="fn">is_exact_instance_of</a><T>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.bool.html">bool</a><div class="where">where
T: PyTypeInfo,</div></h4></section></summary><div class="docblock"><p>Checks whether this object is an instance of exactly type <code>T</code>.</p>
<p>This is equivalent to the Python expression <code>type(self) is T</code>,
if the type <code>T</code> is known at compile time.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.contains" class="method"><h4 class="code-header">pub fn <a href="#method.contains" class="fn">contains</a><V>(&self, value: V) -> <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.bool.html">bool</a>, PyErr><div class="where">where
V: ToPyObject,</div></h4></section></summary><div class="docblock"><p>Determines if self contains <code>value</code>.</p>
<p>This is equivalent to the Python expression <code>value in self</code>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.py" class="method"><h4 class="code-header">pub fn <a href="#method.py" class="fn">py</a>(&self) -> Python<'_></h4></section></summary><div class="docblock"><p>Returns a GIL marker constrained to the lifetime of this type.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.as_ptr" class="method"><h4 class="code-header">pub fn <a href="#method.as_ptr" class="fn">as_ptr</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.pointer.html">*mut </a>PyObject</h4></section></summary><div class="docblock"><p>Returns the raw FFI pointer represented by self.</p>
<h5 id="safety-13"><a href="#safety-13">Safety</a></h5>
<p>Callers are responsible for ensuring that the pointer does not outlive self.</p>
<p>The reference is borrowed; callers should not decrease the reference count
when they are finished with the pointer.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.into_ptr" class="method"><h4 class="code-header">pub fn <a href="#method.into_ptr" class="fn">into_ptr</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.pointer.html">*mut </a>PyObject</h4></section></summary><div class="docblock"><p>Returns an owned raw FFI pointer represented by self.</p>
<h5 id="safety-14"><a href="#safety-14">Safety</a></h5>
<p>The reference is owned; when finished the caller should either transfer ownership
of the pointer or decrease the reference count (e.g. with <a href="crate::ffi::Py_DecRef"><code>pyo3::ffi::Py_DecRef</code></a>).</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.py_super" class="method"><h4 class="code-header">pub fn <a href="#method.py_super" class="fn">py_super</a>(&self) -> <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><&PySuper, PyErr></h4></section></summary><div class="docblock"><p>Return a proxy object that delegates method calls to a parent or sibling class of type.</p>
<p>This is equivalent to the Python expression <code>super()</code></p>
</div></details></div><h2 id="trait-implementations" class="section-header">Trait Implementations<a href="#trait-implementations" class="anchor">§</a></h2><div id="trait-implementations-list"><details class="toggle implementors-toggle" open><summary><section id="impl-Clone-for-PyReadonlyArray%3C'a,+T,+D%3E" class="impl"><a class="src rightside" href="../../src/numpy/borrow/mod.rs.html#327-337">source</a><a href="#impl-Clone-for-PyReadonlyArray%3C'a,+T,+D%3E" class="anchor">§</a><h3 class="code-header">impl<'a, T, D> <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> for <a class="struct" href="struct.PyReadonlyArray.html" title="struct numpy::borrow::PyReadonlyArray">PyReadonlyArray</a><'a, T, D><div class="where">where
T: <a class="trait" href="../trait.Element.html" title="trait numpy::Element">Element</a>,
D: <a class="trait" href="https://docs.rs/ndarray/0.15/ndarray/dimension/dimension_trait/trait.Dimension.html" title="trait ndarray::dimension::dimension_trait::Dimension">Dimension</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.clone" class="method trait-impl"><a class="src rightside" href="../../src/numpy/borrow/mod.rs.html#332-336">source</a><a href="#method.clone" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/core/clone/trait.Clone.html#tymethod.clone" class="fn">clone</a>(&self) -> Self</h4></section></summary><div class='docblock'>Returns a copy of the value. <a href="https://doc.rust-lang.org/1.76.0/core/clone/trait.Clone.html#tymethod.clone">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.clone_from" class="method trait-impl"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="src" href="https://doc.rust-lang.org/1.76.0/src/core/clone.rs.html#169">source</a></span><a href="#method.clone_from" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/core/clone/trait.Clone.html#method.clone_from" class="fn">clone_from</a>(&mut self, source: <a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.reference.html">&Self</a>)</h4></section></summary><div class='docblock'>Performs copy-assignment from <code>source</code>. <a href="https://doc.rust-lang.org/1.76.0/core/clone/trait.Clone.html#method.clone_from">Read more</a></div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-Debug-for-PyReadonlyArray%3C'py,+T,+D%3E" class="impl"><a class="src rightside" href="../../src/numpy/borrow/mod.rs.html#349-363">source</a><a href="#impl-Debug-for-PyReadonlyArray%3C'py,+T,+D%3E" class="anchor">§</a><h3 class="code-header">impl<'py, T, D> <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> for <a class="struct" href="struct.PyReadonlyArray.html" title="struct numpy::borrow::PyReadonlyArray">PyReadonlyArray</a><'py, T, D><div class="where">where
T: <a class="trait" href="../trait.Element.html" title="trait numpy::Element">Element</a>,
D: <a class="trait" href="https://docs.rs/ndarray/0.15/ndarray/dimension/dimension_trait/trait.Dimension.html" title="trait ndarray::dimension::dimension_trait::Dimension">Dimension</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.fmt" class="method trait-impl"><a class="src rightside" href="../../src/numpy/borrow/mod.rs.html#354-362">source</a><a href="#method.fmt" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/core/fmt/trait.Debug.html#tymethod.fmt" class="fn">fmt</a>(&self, f: &mut <a class="struct" href="https://doc.rust-lang.org/1.76.0/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a><'_>) -> <a class="type" href="https://doc.rust-lang.org/1.76.0/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></h4></section></summary><div class='docblock'>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/1.76.0/core/fmt/trait.Debug.html#tymethod.fmt">Read more</a></div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-Deref-for-PyReadonlyArray%3C'py,+T,+D%3E" class="impl"><a class="src rightside" href="../../src/numpy/borrow/mod.rs.html#220-230">source</a><a href="#impl-Deref-for-PyReadonlyArray%3C'py,+T,+D%3E" class="anchor">§</a><h3 class="code-header">impl<'py, T, D> <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/ops/deref/trait.Deref.html" title="trait core::ops::deref::Deref">Deref</a> for <a class="struct" href="struct.PyReadonlyArray.html" title="struct numpy::borrow::PyReadonlyArray">PyReadonlyArray</a><'py, T, D><div class="where">where
T: <a class="trait" href="../trait.Element.html" title="trait numpy::Element">Element</a>,
D: <a class="trait" href="https://docs.rs/ndarray/0.15/ndarray/dimension/dimension_trait/trait.Dimension.html" title="trait ndarray::dimension::dimension_trait::Dimension">Dimension</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle" open><summary><section id="associatedtype.Target" class="associatedtype trait-impl"><a href="#associatedtype.Target" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/1.76.0/core/ops/deref/trait.Deref.html#associatedtype.Target" class="associatedtype">Target</a> = <a class="struct" href="../array/struct.PyArray.html" title="struct numpy::array::PyArray">PyArray</a><T, D></h4></section></summary><div class='docblock'>The resulting type after dereferencing.</div></details><details class="toggle method-toggle" open><summary><section id="method.deref" class="method trait-impl"><a class="src rightside" href="../../src/numpy/borrow/mod.rs.html#227-229">source</a><a href="#method.deref" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/core/ops/deref/trait.Deref.html#tymethod.deref" class="fn">deref</a>(&self) -> &Self::<a class="associatedtype" href="https://doc.rust-lang.org/1.76.0/core/ops/deref/trait.Deref.html#associatedtype.Target" title="type core::ops::deref::Deref::Target">Target</a></h4></section></summary><div class='docblock'>Dereferences the value.</div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-Drop-for-PyReadonlyArray%3C'a,+T,+D%3E" class="impl"><a class="src rightside" href="../../src/numpy/borrow/mod.rs.html#339-347">source</a><a href="#impl-Drop-for-PyReadonlyArray%3C'a,+T,+D%3E" class="anchor">§</a><h3 class="code-header">impl<'a, T, D> <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/ops/drop/trait.Drop.html" title="trait core::ops::drop::Drop">Drop</a> for <a class="struct" href="struct.PyReadonlyArray.html" title="struct numpy::borrow::PyReadonlyArray">PyReadonlyArray</a><'a, T, D><div class="where">where
T: <a class="trait" href="../trait.Element.html" title="trait numpy::Element">Element</a>,
D: <a class="trait" href="https://docs.rs/ndarray/0.15/ndarray/dimension/dimension_trait/trait.Dimension.html" title="trait ndarray::dimension::dimension_trait::Dimension">Dimension</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.drop" class="method trait-impl"><a class="src rightside" href="../../src/numpy/borrow/mod.rs.html#344-346">source</a><a href="#method.drop" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/core/ops/drop/trait.Drop.html#tymethod.drop" class="fn">drop</a>(&mut self)</h4></section></summary><div class='docblock'>Executes the destructor for this type. <a href="https://doc.rust-lang.org/1.76.0/core/ops/drop/trait.Drop.html#tymethod.drop">Read more</a></div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-FromPyObject%3C'py%3E-for-PyReadonlyArray%3C'py,+T,+D%3E" class="impl"><a class="src rightside" href="../../src/numpy/borrow/mod.rs.html#232-237">source</a><a href="#impl-FromPyObject%3C'py%3E-for-PyReadonlyArray%3C'py,+T,+D%3E" class="anchor">§</a><h3 class="code-header">impl<'py, T: <a class="trait" href="../trait.Element.html" title="trait numpy::Element">Element</a>, D: <a class="trait" href="https://docs.rs/ndarray/0.15/ndarray/dimension/dimension_trait/trait.Dimension.html" title="trait ndarray::dimension::dimension_trait::Dimension">Dimension</a>> FromPyObject<'py> for <a class="struct" href="struct.PyReadonlyArray.html" title="struct numpy::borrow::PyReadonlyArray">PyReadonlyArray</a><'py, T, D></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.extract-1" class="method trait-impl"><a class="src rightside" href="../../src/numpy/borrow/mod.rs.html#233-236">source</a><a href="#method.extract-1" class="anchor">§</a><h4 class="code-header">fn <a class="fn">extract</a>(obj: &'py PyAny) -> PyResult<Self></h4></section></summary><div class='docblock'>Extracts <code>Self</code> from the source GIL Ref <code>obj</code>. <a>Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.extract_bound" class="method trait-impl"><a href="#method.extract_bound" class="anchor">§</a><h4 class="code-header">fn <a class="fn">extract_bound</a>(ob: &Bound<'py, PyAny>) -> <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><Self, PyErr></h4></section></summary><div class='docblock'>Extracts <code>Self</code> from the bound smart pointer <code>obj</code>. <a>Read more</a></div></details></div></details></div><h2 id="synthetic-implementations" class="section-header">Auto Trait Implementations<a href="#synthetic-implementations" class="anchor">§</a></h2><div id="synthetic-implementations-list"><section id="impl-RefUnwindSafe-for-PyReadonlyArray%3C'py,+T,+D%3E" class="impl"><a href="#impl-RefUnwindSafe-for-PyReadonlyArray%3C'py,+T,+D%3E" class="anchor">§</a><h3 class="code-header">impl<'py, T, D> !<a class="trait" href="https://doc.rust-lang.org/1.76.0/core/panic/unwind_safe/trait.RefUnwindSafe.html" title="trait core::panic::unwind_safe::RefUnwindSafe">RefUnwindSafe</a> for <a class="struct" href="struct.PyReadonlyArray.html" title="struct numpy::borrow::PyReadonlyArray">PyReadonlyArray</a><'py, T, D></h3></section><section id="impl-Send-for-PyReadonlyArray%3C'py,+T,+D%3E" class="impl"><a href="#impl-Send-for-PyReadonlyArray%3C'py,+T,+D%3E" class="anchor">§</a><h3 class="code-header">impl<'py, T, D> !<a class="trait" href="https://doc.rust-lang.org/1.76.0/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> for <a class="struct" href="struct.PyReadonlyArray.html" title="struct numpy::borrow::PyReadonlyArray">PyReadonlyArray</a><'py, T, D></h3></section><section id="impl-Sync-for-PyReadonlyArray%3C'py,+T,+D%3E" class="impl"><a href="#impl-Sync-for-PyReadonlyArray%3C'py,+T,+D%3E" class="anchor">§</a><h3 class="code-header">impl<'py, T, D> !<a class="trait" href="https://doc.rust-lang.org/1.76.0/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> for <a class="struct" href="struct.PyReadonlyArray.html" title="struct numpy::borrow::PyReadonlyArray">PyReadonlyArray</a><'py, T, D></h3></section><section id="impl-Unpin-for-PyReadonlyArray%3C'py,+T,+D%3E" class="impl"><a href="#impl-Unpin-for-PyReadonlyArray%3C'py,+T,+D%3E" class="anchor">§</a><h3 class="code-header">impl<'py, T, D> <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> for <a class="struct" href="struct.PyReadonlyArray.html" title="struct numpy::borrow::PyReadonlyArray">PyReadonlyArray</a><'py, T, D></h3></section><section id="impl-UnwindSafe-for-PyReadonlyArray%3C'py,+T,+D%3E" class="impl"><a href="#impl-UnwindSafe-for-PyReadonlyArray%3C'py,+T,+D%3E" class="anchor">§</a><h3 class="code-header">impl<'py, T, D> !<a class="trait" href="https://doc.rust-lang.org/1.76.0/core/panic/unwind_safe/trait.UnwindSafe.html" title="trait core::panic::unwind_safe::UnwindSafe">UnwindSafe</a> for <a class="struct" href="struct.PyReadonlyArray.html" title="struct numpy::borrow::PyReadonlyArray">PyReadonlyArray</a><'py, T, D></h3></section></div><h2 id="blanket-implementations" class="section-header">Blanket Implementations<a href="#blanket-implementations" class="anchor">§</a></h2><div id="blanket-implementations-list"><details class="toggle implementors-toggle"><summary><section id="impl-Any-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/core/any.rs.html#140">source</a><a href="#impl-Any-for-T" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/any/trait.Any.html" title="trait core::any::Any">Any</a> for T<div class="where">where
T: 'static + ?<a class="trait" href="https://doc.rust-lang.org/1.76.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.type_id" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/core/any.rs.html#141">source</a><a href="#method.type_id" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/core/any/trait.Any.html#tymethod.type_id" class="fn">type_id</a>(&self) -> <a class="struct" href="https://doc.rust-lang.org/1.76.0/core/any/struct.TypeId.html" title="struct core::any::TypeId">TypeId</a></h4></section></summary><div class='docblock'>Gets the <code>TypeId</code> of <code>self</code>. <a href="https://doc.rust-lang.org/1.76.0/core/any/trait.Any.html#tymethod.type_id">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Borrow%3CT%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/core/borrow.rs.html#208">source</a><a href="#impl-Borrow%3CT%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a><T> for T<div class="where">where
T: ?<a class="trait" href="https://doc.rust-lang.org/1.76.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.borrow" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/core/borrow.rs.html#210">source</a><a href="#method.borrow" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/core/borrow/trait.Borrow.html#tymethod.borrow" class="fn">borrow</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.reference.html">&T</a></h4></section></summary><div class='docblock'>Immutably borrows from an owned value. <a href="https://doc.rust-lang.org/1.76.0/core/borrow/trait.Borrow.html#tymethod.borrow">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-BorrowMut%3CT%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/core/borrow.rs.html#216">source</a><a href="#impl-BorrowMut%3CT%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/borrow/trait.BorrowMut.html" title="trait core::borrow::BorrowMut">BorrowMut</a><T> for T<div class="where">where
T: ?<a class="trait" href="https://doc.rust-lang.org/1.76.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.borrow_mut" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/core/borrow.rs.html#217">source</a><a href="#method.borrow_mut" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut" class="fn">borrow_mut</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.reference.html">&mut T</a></h4></section></summary><div class='docblock'>Mutably borrows from an owned value. <a href="https://doc.rust-lang.org/1.76.0/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-From%3CT%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/core/convert/mod.rs.html#763">source</a><a href="#impl-From%3CT%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/convert/trait.From.html" title="trait core::convert::From">From</a><T> for T</h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.from" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/core/convert/mod.rs.html#766">source</a><a href="#method.from" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/core/convert/trait.From.html#tymethod.from" class="fn">from</a>(t: T) -> T</h4></section></summary><div class="docblock"><p>Returns the argument unchanged.</p>
</div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-FromPyObjectBound%3C'_,+'py%3E-for-T" class="impl"><a href="#impl-FromPyObjectBound%3C'_,+'py%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<'py, T> FromPyObjectBound<'_, 'py> for T<div class="where">where
T: FromPyObject<'py>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.from_py_object_bound" class="method trait-impl"><a href="#method.from_py_object_bound" class="anchor">§</a><h4 class="code-header">fn <a class="fn">from_py_object_bound</a>(ob: &Bound<'py, PyAny>) -> <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><T, PyErr></h4></section></summary><div class='docblock'>Extracts <code>Self</code> from the bound smart pointer <code>obj</code>. <a>Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Into%3CU%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/core/convert/mod.rs.html#747-749">source</a><a href="#impl-Into%3CU%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><U> for T<div class="where">where
U: <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/convert/trait.From.html" title="trait core::convert::From">From</a><T>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.into" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/core/convert/mod.rs.html#756">source</a><a href="#method.into" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/core/convert/trait.Into.html#tymethod.into" class="fn">into</a>(self) -> U</h4></section></summary><div class="docblock"><p>Calls <code>U::from(self)</code>.</p>
<p>That is, this conversion is whatever the implementation of
<code><a href="https://doc.rust-lang.org/1.76.0/core/convert/trait.From.html" title="trait core::convert::From">From</a><T> for U</code> chooses to do.</p>
</div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Same-for-T" class="impl"><a class="src rightside" href="https://docs.rs/typenum/1.17.0/src/typenum/type_operators.rs.html#34">source</a><a href="#impl-Same-for-T" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://docs.rs/typenum/1.17.0/typenum/type_operators/trait.Same.html" title="trait typenum::type_operators::Same">Same</a> for T</h3></section></summary><div class="impl-items"><details class="toggle" open><summary><section id="associatedtype.Output" class="associatedtype trait-impl"><a href="#associatedtype.Output" class="anchor">§</a><h4 class="code-header">type <a href="https://docs.rs/typenum/1.17.0/typenum/type_operators/trait.Same.html#associatedtype.Output" class="associatedtype">Output</a> = T</h4></section></summary><div class='docblock'>Should always be <code>Self</code></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-SupersetOf%3CSS%3E-for-SP" class="impl"><a href="#impl-SupersetOf%3CSS%3E-for-SP" class="anchor">§</a><h3 class="code-header">impl<SS, SP> SupersetOf<SS> for SP<div class="where">where
SS: SubsetOf<SP>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.to_subset" class="method trait-impl"><a href="#method.to_subset" class="anchor">§</a><h4 class="code-header">fn <a class="fn">to_subset</a>(&self) -> <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a><SS></h4></section></summary><div class='docblock'>The inverse inclusion map: attempts to construct <code>self</code> from the equivalent element of its
superset. <a>Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.is_in_subset" class="method trait-impl"><a href="#method.is_in_subset" class="anchor">§</a><h4 class="code-header">fn <a class="fn">is_in_subset</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.bool.html">bool</a></h4></section></summary><div class='docblock'>Checks if <code>self</code> is actually part of its subset <code>T</code> (and can be converted to it).</div></details><details class="toggle method-toggle" open><summary><section id="method.to_subset_unchecked" class="method trait-impl"><a href="#method.to_subset_unchecked" class="anchor">§</a><h4 class="code-header">fn <a class="fn">to_subset_unchecked</a>(&self) -> SS</h4></section></summary><div class='docblock'>Use with care! Same as <code>self.to_subset</code> but without any property checks. Always succeeds.</div></details><details class="toggle method-toggle" open><summary><section id="method.from_subset" class="method trait-impl"><a href="#method.from_subset" class="anchor">§</a><h4 class="code-header">fn <a class="fn">from_subset</a>(element: <a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.reference.html">&SS</a>) -> SP</h4></section></summary><div class='docblock'>The inclusion map: converts <code>self</code> to the equivalent element of its superset.</div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-ToOwned-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/alloc/borrow.rs.html#83-85">source</a><a href="#impl-ToOwned-for-T" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/1.76.0/alloc/borrow/trait.ToOwned.html" title="trait alloc::borrow::ToOwned">ToOwned</a> for T<div class="where">where
T: <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle" open><summary><section id="associatedtype.Owned" class="associatedtype trait-impl"><a href="#associatedtype.Owned" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/1.76.0/alloc/borrow/trait.ToOwned.html#associatedtype.Owned" class="associatedtype">Owned</a> = T</h4></section></summary><div class='docblock'>The resulting type after obtaining ownership.</div></details><details class="toggle method-toggle" open><summary><section id="method.to_owned-1" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/alloc/borrow.rs.html#88">source</a><a href="#method.to_owned-1" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/alloc/borrow/trait.ToOwned.html#tymethod.to_owned" class="fn">to_owned</a>(&self) -> T</h4></section></summary><div class='docblock'>Creates owned data from borrowed data, usually by cloning. <a href="https://doc.rust-lang.org/1.76.0/alloc/borrow/trait.ToOwned.html#tymethod.to_owned">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.clone_into" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/alloc/borrow.rs.html#92">source</a><a href="#method.clone_into" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/alloc/borrow/trait.ToOwned.html#method.clone_into" class="fn">clone_into</a>(&self, target: <a class="primitive" href="https://doc.rust-lang.org/1.76.0/std/primitive.reference.html">&mut T</a>)</h4></section></summary><div class='docblock'>Uses borrowed data to replace owned data, usually by cloning. <a href="https://doc.rust-lang.org/1.76.0/alloc/borrow/trait.ToOwned.html#method.clone_into">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-TryFrom%3CU%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/core/convert/mod.rs.html#803-805">source</a><a href="#impl-TryFrom%3CU%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U> for T<div class="where">where
U: <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><T>,</div></h3></section></summary><div class="impl-items"><details class="toggle" open><summary><section id="associatedtype.Error" class="associatedtype trait-impl"><a href="#associatedtype.Error" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/1.76.0/core/convert/trait.TryFrom.html#associatedtype.Error" class="associatedtype">Error</a> = <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/convert/enum.Infallible.html" title="enum core::convert::Infallible">Infallible</a></h4></section></summary><div class='docblock'>The type returned in the event of a conversion error.</div></details><details class="toggle method-toggle" open><summary><section id="method.try_from" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/core/convert/mod.rs.html#810">source</a><a href="#method.try_from" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/core/convert/trait.TryFrom.html#tymethod.try_from" class="fn">try_from</a>(value: U) -> <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><T, <T as <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U>>::<a class="associatedtype" href="https://doc.rust-lang.org/1.76.0/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></h4></section></summary><div class='docblock'>Performs the conversion.</div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-TryInto%3CU%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/core/convert/mod.rs.html#788-790">source</a><a href="#impl-TryInto%3CU%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/convert/trait.TryInto.html" title="trait core::convert::TryInto">TryInto</a><U> for T<div class="where">where
U: <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>,</div></h3></section></summary><div class="impl-items"><details class="toggle" open><summary><section id="associatedtype.Error-1" class="associatedtype trait-impl"><a href="#associatedtype.Error-1" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/1.76.0/core/convert/trait.TryInto.html#associatedtype.Error" class="associatedtype">Error</a> = <U as <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="associatedtype" href="https://doc.rust-lang.org/1.76.0/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a></h4></section></summary><div class='docblock'>The type returned in the event of a conversion error.</div></details><details class="toggle method-toggle" open><summary><section id="method.try_into" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/core/convert/mod.rs.html#795">source</a><a href="#method.try_into" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/core/convert/trait.TryInto.html#tymethod.try_into" class="fn">try_into</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><U, <U as <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="associatedtype" href="https://doc.rust-lang.org/1.76.0/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></h4></section></summary><div class='docblock'>Performs the conversion.</div></details></div></details></div></section></div></main></body></html>