logo
  • 教程列表
  • SO官方文檔
  • 壽命
    • 更高階別的特質界限
    • Impl 塊
    • 功能引數(輸入壽命)
    • 結構欄位
  1. StackOverflow 文件
  2. Rust 教程
  3. 壽命
  4. Impl 塊

Impl 塊

Created: November-22, 2018

impl<'a> Type<'a> {
    fn my_function(&self) -> &'a u32 {
        self.x
    }
}

這指定 Type 具有生命期'a,並且 my_function() 返回的引用可能在'a 結束後不再有效,因為 Type 不再存在以保持 self.x。

  • 功能引數(輸入壽命)
  • 更高階別的特質界限

Copyright © 2018. All right reserved

tastones.com 备案号:鲁ICP备18045372号-1

  • 關於本站
  • 免責聲明