Re: The Case for Rust (in any system)
- In reply to: Steffen Nurpmeso : "Re: The Case for Rust (in any system)"
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 05 Sep 2024 23:03:01 UTC
Steffen Nurpmeso wrote in <20240905225129.UvYYMXDa@steffen%sdaoden.eu>: ... hihihi saw the Somers .. but wanted to add |Ie, if you implement some SCSI command .. | we_parse_THIS_SCSI_COMMAND([.]u8 *buf, u16 len){ |... | /* C99 */{ | struct a_mmc_cmd_x42_resp_data_head *dhp; | |^argument etc of THIS_SCSI_COMMAND | | dhp = R(struct a_mmc_cmd_x42_resp_data_head*,buf); | buf += sizeof(*dhp); | len -= sizeof(*dhp); |} |... | irp = R(struct a_mmc_cmd_x42_isrc_resp*,buf); This thing tested the lengths accordingly, of course. ... |very safely in C, if instead of strnlen() etc something more sane |would have been used. Like a string object. But it is more |typing work etc. *That* of course, yes. Now Option<Box<Vec<u8>>> or Vec::with_capacity(262144) is not that much shorter than doing something in C proper types at hand provided. (Btw C object constructors usually initialize their types, too, .. that is why they are called constructors. Of course: you need these objects, stdlib has none, but FILE, which is horrific. Vec<u8>, hmhm...) ..etcetcetc. --steffen | |Der Kragenbaer, The moon bear, |der holt sich munter he cheerfully and one by one |einen nach dem anderen runter wa.ks himself off |(By Robert Gernhardt)