这样是可以的。但是如果是在函数里交换传进来的两个引用:
就会报lifetime有关的错误:
这是因为交换引用的时候,两个引用的生命周期必须是相等的,因此在函数参数里指定两个引用的生命周期相同即可:
当然,也可以用swap
:
参考:https://stackoverflow.com/questions/53835730/swapping-two-local-references-leads-to-lifetime-error
这样是可以的。但是如果是在函数里交换传进来的两个引用:
就会报lifetime有关的错误:
这是因为交换引用的时候,两个引用的生命周期必须是相等的,因此在函数参数里指定两个引用的生命周期相同即可:
当然,也可以用swap
:
参考:https://stackoverflow.com/questions/53835730/swapping-two-local-references-leads-to-lifetime-error
上一篇:qemu gdb lx-symbols Python Exception <class ‘gdb.MemoryError‘> Cannot access memory at address 0xfff
下一篇:qemu挂载物理磁盘
简单的swap(integer i1.,integer i2),原本以为就是简单的对象之间的交换,
举报文章
请选择举报类型
补充说明
0/200
上传截图
格式支持JPEG/PNG/JPG,图片不超过1.9M