上一页 1 ··· 68 69 70 71 72 73 74 75 76 ··· 494 下一页
摘要: `Option` and `Result` are two very central enums in Rust, and they are used for error handling and for representing the absence of a value. Here is a 阅读全文
posted @ 2023-05-24 13:57 Zhentiw 阅读(92) 评论(0) 推荐(0)
摘要: Typescript: import fs from "fs"; const fileName = process.argv[2]; if (fileName) { fs.readFileSync(fileName) .toString() .split("\n") .map((num) => pa 阅读全文
posted @ 2023-05-24 13:52 Zhentiw 阅读(25) 评论(0) 推荐(0)
摘要: Typescript: function practice(nums: number[], index: number): number { return (nums[index] ?? index) * 5 } In Rust: fn practice(nums: Vec<usize>, inde 阅读全文
posted @ 2023-05-24 01:24 Zhentiw 阅读(15) 评论(0) 推荐(0)
摘要: background.ts: // TODO: background script chrome.runtime.onInstalled.addListener(() => { console.log("onInstalled..."); }); chrome.webRequest.onBefore 阅读全文
posted @ 2023-05-22 14:39 Zhentiw 阅读(136) 评论(0) 推荐(0)
摘要: // Imagine NavBar is an external library! export const NavBar = (props: { title: string; links: string[]; children: React.ReactNode; }) => { return <d 阅读全文
posted @ 2023-05-22 14:11 Zhentiw 阅读(17) 评论(0) 推荐(0)
摘要: Using Omit import { ComponentProps } from 'react'; import { Equal, Expect } from '../helpers/type-utils'; export const Input = ( props: Omit<Component 阅读全文
posted @ 2023-05-22 13:58 Zhentiw 阅读(52) 评论(0) 推荐(0)
摘要: Relevant for components that accept other React components as props. export declare interface AppProps { children?: React.ReactNode; // best, accepts 阅读全文
posted @ 2023-05-22 13:24 Zhentiw 阅读(28) 评论(0) 推荐(0)
摘要: fn multiply(num: Option<usize>) -> usize { return num.unwrap_or(0) * 5; } fn multiply1(num: Option<usize>) -> Option<usize> { match num { Some(num) => 阅读全文
posted @ 2023-05-18 20:32 Zhentiw 阅读(28) 评论(0) 推荐(0)
摘要: enum Color { Red, Green, Blue, Yellow, } impl Color { fn is_green(&self) -> bool { if let Color::Green = self { return true; } return false; } fn is_g 阅读全文
posted @ 2023-05-17 14:53 Zhentiw 阅读(33) 评论(0) 推荐(0)
摘要: Typescript import * as fs from "fs"; fs.readFileSync("project/lines", { encoding: "utf-8" }) .toString() .split("\n") .filter((_, i) => i % 2 0) .filt 阅读全文
posted @ 2023-05-16 14:34 Zhentiw 阅读(22) 评论(0) 推荐(0)
上一页 1 ··· 68 69 70 71 72 73 74 75 76 ··· 494 下一页