上一页 1 ··· 73 74 75 76 77 78 79 80 81 ··· 499 下一页
摘要: 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 阅读(34) 评论(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 阅读(25) 评论(0) 推荐(0)
摘要: background.ts: // TODO: background script chrome.runtime.onInstalled.addListener(() => { console.log("onInstalled..."); }); chrome.webRequest.onBefore 阅读全文
posted @ 2023-05-22 14:39 Zhentiw 阅读(147) 评论(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 阅读(21) 评论(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 阅读(58) 评论(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 阅读(47) 评论(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 阅读(37) 评论(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 阅读(43) 评论(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 阅读(34) 评论(0) 推荐(0)
摘要: String collect: automaticlly calling concat on string let foo: String = vec!["this", "is", "a", "test"] .into_iter() .collect(); println!("{:?}", foo) 阅读全文
posted @ 2023-05-15 15:01 Zhentiw 阅读(104) 评论(0) 推荐(0)
上一页 1 ··· 73 74 75 76 77 78 79 80 81 ··· 499 下一页