blob_id
stringlengths
40
40
language
stringclasses
1 value
repo_name
stringlengths
5
140
path
stringlengths
5
183
src_encoding
stringclasses
6 values
length_bytes
int64
12
5.32M
score
float64
2.52
4.94
int_score
int64
3
5
detected_licenses
listlengths
0
47
license_type
stringclasses
2 values
text
stringlengths
12
5.32M
download_success
bool
1 class
7fd7454bd36ab7255e9f7678f47707cf79e52431
Rust
Blue-Pix/ezio
/src/cookbook/science/mod.rs
UTF-8
7,941
3.140625
3
[ "Apache-2.0" ]
permissive
use approx::assert_abs_diff_eq; use ndarray::{arr1, arr2, array, Array, Array1, ArrayView1}; use nalgebra::{Matrix3, DMatrix}; use num::complex::Complex; use std::cmp::Ordering; use std::collections::HashMap; use num::bigint::{BigInt, ToBigInt}; pub fn add_matrix() { let a = arr2(&[ [1, 2, 3], [4, 5, 6], ]...
true
ae4d560740b28a221e8817831302d17827c69721
Rust
jklina/rusty_space_clawer
/src/team.rs
UTF-8
310
2.640625
3
[]
no_license
use std::fmt; use serde::{Serialize, Deserialize}; use cli_table::Table; #[derive(Table, Serialize, Deserialize, Debug)] pub struct Team { id: i32, name: String, } impl fmt::Display for Team { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{}", self.name) } }
true
896363f336251e91555e2cd0d8eac39b06478d6d
Rust
Krakaw/mock-pop
/src/pop/command.rs
UTF-8
3,086
3.203125
3
[]
no_license
#[derive(Debug)] pub enum Command { User(Option<String>), Pass(Option<String>), Noop, Rset, Quit, Uidl, Stat, List, Retr(u32), Dele(u32), Capa, Auth, } impl Command { pub fn from_str(s: &str) -> Option<Command> { let parts = s.trim().to_uppercase(); l...
true
f230a1e3ad62ff4003d9294551fb2adbeccd5067
Rust
supython-coder/leetcode-rust
/S0451-sort-characters-by-frequency/src/main.rs
UTF-8
824
3.234375
3
[]
no_license
struct Solution; use std::cmp::Ordering; use std::collections::HashMap; impl Solution { pub fn frequency_sort(s: String) -> String { let mut char_cnt = HashMap::new(); s.bytes().for_each(|c| { char_cnt.entry(c).and_modify(|e| *e += 1).or_insert(1); }); let mut byte_arr ...
true
4a316fbfd7b54b6e3d44ea042f2207404b0e7a27
Rust
benwr/exercises
/mackay/src/lib.rs
UTF-8
7,070
3.234375
3
[]
no_license
pub mod encodings { use std::clone::Clone; pub trait Encoder<Input: Clone, Output: Clone> { fn encode(&self, message: &[Input]) -> Vec<Output>; fn decode(&self, message: &[Output]) -> Vec<Input>; } pub struct Composition<Symbol> { components: Vec<Box<Encoder<Symbol, Symbol>>>, } impl<Symbol: Clone> Comp...
true
eb9d76e0999b2b35250a88f2f20767913b0c016e
Rust
RoccoDev/bson-rust
/src/datetime.rs
UTF-8
7,646
3.34375
3
[ "MIT" ]
permissive
use std::{ fmt::{self, Display}, time::{Duration, SystemTime}, }; use chrono::{LocalResult, TimeZone, Utc}; /// Struct representing a BSON datetime. /// Note: BSON datetimes have millisecond precision. /// /// To enable conversions between this type and [`chrono::DateTime`], enable the `"chrono-0_4"` /// feat...
true
475fd221d18413b00e3a1b7fef7bb13a1ddaac4e
Rust
kunicmarko20/exercism.io
/rust/prime-factors/src/lib.rs
UTF-8
560
3.296875
3
[]
no_license
pub fn factors(n: u64) -> Vec<u64> { if n < 2 { return vec!(); } let mut prime_factors: Vec<u64> = Vec::new(); let mut result = n.clone(); while result != 1 { let next_prime_factor = next_prime_factor(result, n).unwrap(); result = result / next_prime_factor; prime_f...
true
35210a336c22971c5bf20fe1d867ec9aba21a131
Rust
brnkes/2019-aoc-stuff
/d15/src/lib/arcade.rs
UTF-8
1,785
3.1875
3
[]
no_license
use super::robot::{Canvas, Coords}; use std::collections::HashMap; use std::hash::Hash; use wasm_bindgen::prelude::*; use super::robot::get_canvas_from_coords; #[wasm_bindgen] pub struct Arcade { visited_coords: HashMap<Coords,u64>, // joystick: i8, score: u64 } #[wasm_bindgen] impl Arcade { pub fn new...
true
47bec3f909d70ba587b2ff7aa01c2faf2ce4871a
Rust
yeochinyi/codetest
/exercism/rust/minesweeper/src/lib.rs
UTF-8
1,316
2.984375
3
[]
no_license
use std::collections::HashMap; pub fn annotate(minefield: &[&str]) -> Vec<String> { let mut m: HashMap<(isize, isize), usize> = HashMap::new(); (0..minefield.len()).for_each(|x| { (0..minefield[x].len()).for_each(|y| { count(&mut m, minefield, x, y); }) }); //println!("{:?}"...
true
522404584fbf4313842d5bc59dc14f77d0d3d685
Rust
Jaic1/xv6-riscv-rust
/src/register/mie.rs
UTF-8
375
2.734375
3
[ "MIT" ]
permissive
//! mie register use bit_field::BitField; #[inline] unsafe fn read() -> usize { let ret: usize; llvm_asm!("csrr $0, mie":"=r"(ret):::"volatile"); ret } #[inline] unsafe fn write(x: usize) { llvm_asm!("csrw mie, $0"::"r"(x)::"volatile"); } /// set MTIE field pub unsafe fn set_mtie() { let mut mie...
true
a60d9f7ced293fdc3305541bcdcea48f5d125b6c
Rust
emmiegit/slog-mock
/src/lib.rs
UTF-8
1,574
2.53125
3
[ "MIT" ]
permissive
/* * lib.rs * * slog-mock - Mock crate for slog to compile out all logging. * Copyright (c) 2021 Ammon Smith * * slog-mock is available free of charge under the terms of the MIT * License. You are free to redistribute and/or modify it under those * terms. It is distributed in the hopes that it will be useful, b...
true
bc383163d9346a9430becd97ca37f475a9474985
Rust
paritytech/substrate
/primitives/core/src/hash.rs
UTF-8
3,887
2.734375
3
[ "Apache-2.0", "GPL-3.0-or-later", "Classpath-exception-2.0", "GPL-1.0-or-later", "GPL-3.0-only" ]
permissive
// This file is part of Substrate. // Copyright (C) Parity Technologies (UK) Ltd. // SPDX-License-Identifier: Apache-2.0 // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.a...
true
fcd0c747ff6496308e15a50b2edf871ddce38041
Rust
CodeSandwich/rust-cardano
/chain-impl-mockchain/src/block.rs
UTF-8
5,255
3.078125
3
[ "MIT" ]
permissive
//! Representation of the block in the mockchain. use crate::key::*; use crate::transaction::*; use bincode; use chain_core::property; /// Non unique identifier of the transaction position in the /// blockchain. There may be many transactions related to the same /// `SlotId`. #[derive(Debug, Copy, Clone, PartialEq, Eq...
true
a82e62cd2651aa21172ec09f6f29bdf66d480625
Rust
twtvfhpfm/rust_exercise
/exercise/src/vec_.rs
UTF-8
465
2.921875
3
[]
no_license
pub fn test_vec() { let mut v = vec![Vec::new(),Vec::new(),Vec::new()]; let mut v1 = &mut v[1]; v1.push(1); let mut v0 = &mut v[0]; v0.push(0); println!("{:?}", v); println!("{}", v[0][0]); let mut s1 = String::from("hello"); let mut s2 = String::from("world"); let mut s3 = s1 +...
true
a614c9e820449d5429fc083bb97e2742400f0ec5
Rust
tanacchi/actix-webapp
/src/handlers.rs
UTF-8
5,359
2.609375
3
[ "MIT" ]
permissive
use actix_web::{ web, HttpResponse, Result }; use crate::state; use crate::param; use crate::templates; pub async fn index(data: web::Data<state::AppState>) -> String { let app_name = &data.app_name; format!("Hello {}!", app_name) } pub async fn dashboard(id: Identity) -> Result<HttpResponse> { let lo...
true
66d81f0da1cf74053cd49f640f5721d3925c5f1c
Rust
ci123chain/ci123chain-cdk
/src/runtime.rs
UTF-8
8,523
2.59375
3
[]
no_license
use crate::codec::Sink; use crate::types::{Address, ContractResult, Response}; use crate::prelude::{panic, vec, Vec}; const INPUT_TOKEN: i32 = 0; static mut PANIC_HOOK: bool = false; pub fn make_dependencies() -> Dependencies { unsafe { if PANIC_HOOK == false { panic::set_hook(Box::new(|pani...
true
2dc1e1a0479524f95f3e62afc478d6debde020fa
Rust
MingweiChen/SAT_Solver
/src/test/mod.rs
UTF-8
6,039
2.5625
3
[]
no_license
use sat::sat_lib::*; use std::vec::Vec; use rand::Rng; use time::now; extern crate sat; extern crate rand; extern crate time; pub fn test() { sat_test(); println!("Correctness Test: "); random_correctness_test(1000); println!("\nEfficiency Test: "); random_efficiency_test(3); } fn sat_test() { // (1\/~6\/8)/\...
true
697ba8a0007559e29374902f0eb3c9ee1c6080d1
Rust
PWhiddy/nannou
/nannou-new/src/main.rs
UTF-8
6,304
3.140625
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! A simple tool for creating a new nannou project. //! //! 1. Determines whether the user is just sketching or wants an App (with model and event `fn`s). //! 2. Asks for a sketch/app name. extern crate names; extern crate rand; use std::env; use std::io::{self, BufRead, Write}; use std::fs::{self, File}; use std::p...
true
b584ed861844bdccbfe65efc47e5af0ebecef478
Rust
yohandev/voxels
/voxels/src/common/block/face.rs
UTF-8
2,468
3.90625
4
[]
no_license
use ezmath::*; /// block face enum, in global coordinates. /// that means a block's right face, for example /// is always right no matter how it's rotated. #[derive(Debug, Copy, Clone, Eq, PartialEq)] #[allow(dead_code)] #[repr(u8)] pub enum BlockFace { /// -z North = 0, /// +z South = 1, /// -...
true
310742bfdc369bf17f2b3632a9ad61869c71f7cc
Rust
jthelin/demikernel
/src/rust/scheduler/yielder.rs
UTF-8
4,499
2.953125
3
[ "MIT" ]
permissive
// Copyright (c) Microsoft Corporation. // Licensed under the MIT license. //====================================================================================================================== // Imports //==============================================================================================================...
true
d667b7b6120d6be07db0d0c3f1db42d5efd1a45a
Rust
DuncanCasteleyn/07th-mod-python-patcher
/install_loader/src/config.rs
UTF-8
795
2.6875
3
[]
no_license
use crate::windows_utilities; use imgui::ImString; use std::path::PathBuf; // Please define these as paths relative to the current directory pub struct InstallerConfig { pub sub_folder: PathBuf, pub sub_folder_display: ImString, pub logs_folder: PathBuf, pub python_path: PathBuf, pub is_retry: bool, } impl Insta...
true
4b01d6c8c273b25658b46c0e1f2db1c154c4d1ba
Rust
brunoczim/lockfree
/src/channel/spmc.rs
UTF-8
13,403
2.96875
3
[ "MIT" ]
permissive
pub use super::{ NoRecv, RecvErr::{self, *}, }; use incin::Pause; use owned_alloc::OwnedAlloc; use ptr::{bypass_null, check_null_align}; use removable::Removable; use std::{ fmt, ptr::{null_mut, NonNull}, sync::{ atomic::{AtomicPtr, Ordering::*}, Arc, }, }; /// Creates an asynch...
true
c1199f8a013d6d03d20d66e0a7fe5528ed6d434c
Rust
eeeeeta/inebriated-rs-edition
/src/rgen.rs
UTF-8
1,455
2.9375
3
[]
no_license
extern crate rand; use markov; use rand::distributions::{Weighted, WeightedChoice, IndependentSample}; pub trait HasWeight { fn getwt(&self) -> u32; } pub fn pick_from_vec<T>(vec: &Vec<T>) -> Option<&T> where T: HasWeight { match vec.len() { 0 => None, 1 => Some(&vec[0]), _ => { ...
true
809505a854aa6072d49afb5cbd71525d64b89905
Rust
smartbrainisme/queen
/test/test_stream_ext.rs
UTF-8
7,247
2.609375
3
[ "MIT" ]
permissive
use std::time::Duration; use std::thread; use std::sync::{Arc, Mutex}; use queen::{Queen, Node, Port}; use queen::nson::{msg, MessageId}; use queen::error::{Error, ErrorCode}; use queen::net::CryptoOptions; use queen::crypto::Method; use queen::dict::*; use queen::stream::StreamExt; use super::get_free_addr; #[test...
true
ba6658fed022c030ef995ecb7e6bc1863b07e482
Rust
Kha/elan
/src/elan-dist/src/manifest.rs
UTF-8
1,217
3.09375
3
[ "Apache-2.0" ]
permissive
//! Lean distribution v2 manifests. //! //! This manifest describes the distributable artifacts for a single //! release of Lean. They are toml files, typically downloaded from //! e.g. static.lean-lang.org/dist/channel-lean-nightly.toml. They //! describe where to download, for all platforms, each component of //! the...
true
982cd0ff814ceb9241fa7142661650068d344b2a
Rust
peter-fomin/rust-playground
/rna-transcription/src/lib.rs
UTF-8
1,636
3.375
3
[]
no_license
#[derive(Debug, PartialEq)] pub struct DNA; #[derive(Debug, PartialEq)] pub struct RNA; #[derive(Debug, PartialEq)] pub struct NucleicAcid { sequence: Vec<char>, acid: Acid, } #[derive(Debug, PartialEq)] pub enum Acid { DNA, RNA, } impl DNA { pub fn new(sequence: &str) -> Result<NucleicAcid, usi...
true
87871a2d84e90ba38cd6a63d3d56227fa43cf215
Rust
leshow/exercism
/hackerrank/src/simple_text_editor.rs
UTF-8
1,851
3.15625
3
[]
no_license
use crate::scanner::*; use std::io::{self, BufWriter, Write}; #[derive(Clone, Debug)] enum Op<T> { Append { value: T }, Del { idx: usize }, Print { idx: usize }, Undo, } fn main() -> Result<(), Box<dyn std::error::Error>> { let mut scan = Scanner::default(); let out = &mut BufWriter::new(io::...
true
43e1e5487a4d000ae5a50eca737729b898f90cbc
Rust
sweisser/rust-serverless-example
/src/main.rs
UTF-8
1,856
2.953125
3
[]
no_license
use lambda_runtime::{Context, error::HandlerError}; use lambda_http::{lambda, Request, IntoResponse, RequestExt}; use serde_derive::{Serialize, Deserialize}; use serde_json::json; use rust_serverless_example::{ compute_holidays, Holidays }; use std::fmt; fn main() { lambda!(handler) } fn handler( request: Req...
true
e3cf9be3fed198fdb82764bfc371b29cf176be0c
Rust
DougLau/pix
/src/rgb.rs
UTF-8
9,907
3.265625
3
[ "Apache-2.0", "MIT" ]
permissive
// rgb.rs RGB color model. // // Copyright (c) 2018-2022 Douglas P Lau // Copyright (c) 2019-2020 Jeron Aldaron Lau // //! [RGB] color model and types. //! //! [rgb]: https://en.wikipedia.org/wiki/RGB_color_model use crate::chan::{Ch16, Ch32, Ch8, Linear, Premultiplied, Srgb, Straight}; use crate::el::{Pix3, Pi...
true
2666d2c25a49b971cfde52335fa57432ec049eda
Rust
Azure/azure-sdk-for-rust
/services/mgmt/maps/src/package_preview_2020_02/models.rs
UTF-8
22,791
2.703125
3
[ "LicenseRef-scancode-generic-cla", "MIT", "LGPL-2.1-or-later" ]
permissive
#![allow(non_camel_case_types)] #![allow(unused_imports)] use serde::de::{value, Deserializer, IntoDeserializer}; use serde::{Deserialize, Serialize, Serializer}; use std::str::FromStr; #[doc = "An Azure resource which represents Maps Creator product and provides ability to manage private location data."] #[derive(Clon...
true
f676b371980e88e3d9aec1259071369df32ce70b
Rust
seanpianka/leetcode-rust
/src/data_structure/heap/top_k_frequent_elements.rs
UTF-8
3,269
3.71875
4
[]
no_license
//! https://leetcode.com/problems/top-k-frequent-elements/ //! 解题思路类似: <https://leetcode.com/problems/kth-largest-element-in-a-stream/> /// return [num for num, _ in collections.Counter(nums).most_common(k)] fn top_k_frequent_elements(nums: Vec<i32>, k: i32) -> Vec<i32> { let k = k as usize; let n = nums.len()...
true
d2da768a039c09303f9c87bb8659be9fc78f6cd1
Rust
amadeusine/blisp
/src/coq.rs
UTF-8
8,089
2.703125
3
[ "MIT" ]
permissive
use super::semantics as S; use alloc::collections::LinkedList; use alloc::format; use alloc::string::{String, ToString}; pub(crate) fn to_coq_type( expr: &S::TypeExpr, depth: usize, targs: &mut LinkedList<String>, ) -> String { match expr { S::TypeExpr::TEBool(_) => "bool".to_string(), ...
true
514a368505dc32e15b0f8f1cadf7cf87068d585c
Rust
gba-rs/web-frontend
/src/components/registers.rs
UTF-8
6,067
2.96875
3
[ "Apache-2.0", "MIT" ]
permissive
use yew::prelude::*; use yew::{html, Component, ComponentLink, InputData, KeyboardEvent, Html, ShouldRender}; use gba_emulator::gba::GBA; use std::rc::Rc; use std::cell::RefCell; use log::{info}; pub struct Registers { props: RegistersProp, updated_reg_hex: String, updated_reg_dec: String, update_reg_n...
true
217f02c11f3f712ce4160d6dc4802ecd82a46668
Rust
gskapka/etheroff
/src/interactive_cli_lib/get_eth_gas_price.rs
UTF-8
675
2.90625
3
[]
no_license
use crate::{ interactive_cli_lib::{state::InteractiveCliState, utils::get_user_input}, lib::types::Result, }; pub fn get_eth_gas_price_from_user(state: InteractiveCliState) -> Result<InteractiveCliState> { println!("❍ Please enter the gas price for the transaction (in GWEI):"); get_user_input().and_the...
true
39a0d833928d5a0ec0e689b46f8565ae7f629873
Rust
rstropek/rust-samples
/memory-management/040-Rc/src/main.rs
UTF-8
720
3.453125
3
[]
no_license
use std::rc::Rc; #[derive(Debug)] struct MyPrecious { ring: i32, } impl Drop for MyPrecious { fn drop(&mut self) { println!("Dropping {:?}", self); } } fn main() { let mine = Box::new(MyPrecious{ ring: 21 }); let also_mine = mine; //println!("{:?}", mine); // Does not work println...
true
d7411140ec10bd5a35dc0e496708a909342ff8b2
Rust
marlon-bain/aoc2019
/day1/src/main.rs
UTF-8
756
3.328125
3
[]
no_license
use aoc::utils::get_ints; fn get_fuel(mass: i32) -> i32 { let tentative = ((mass / 3) as i32) - 2; if tentative < 0 { return 0; } tentative } fn main() { let values = get_ints("input.txt"); // Part 1 { let mut result = 0; for value in values.clone() { ...
true
8895a9982139e1b8ba83d574a317f4df6d207965
Rust
jaffa4/siko-1
/crates/siko_interpreter/src/std_ops.rs
UTF-8
1,343
2.59375
3
[ "MIT" ]
permissive
use crate::environment::Environment; use crate::extern_function::ExternFunction; use crate::interpreter::Interpreter; use crate::value::Value; use siko_ir::expr::ExprId; use siko_ir::function::NamedFunctionKind; use siko_ir::types::Type; pub struct And {} impl ExternFunction for And { fn call( &self, ...
true
362c38ff8a53c41faf85ff85ee328cf5ad1fb7ea
Rust
hubris-lang/hubris
/src/hubris/core/name.rs
UTF-8
5,701
3.03125
3
[ "MIT" ]
permissive
use super::super::ast::{Span, HasSpan}; use std::fmt::{self, Display, Formatter}; use std::hash::{Hash, Hasher}; use super::Term; use super::BindingMode; use super::super::pretty::*; #[derive(Clone, Debug, Eq)] pub enum Name { DeBruijn { index: usize, span: Span, repr: String, }, ...
true
47c6ae5b203297d8bf25d781d14b3941b7bf2239
Rust
zoniony/sdz
/src/corpus/inputs.rs
UTF-8
531
2.9375
3
[]
no_license
use std::{ fs::File, io::{Read}, path::Path }; use crate::corpus::Inputs; #[derive(Debug)] pub struct BytesInput { pub bytes: Vec<u8>, } impl Inputs for BytesInput { fn read_file<P>(path: P) -> Self where P: AsRef<Path>, { let mut file = File::open(path).unwrap(); ...
true
71af673b38833bd8c8d6905738bde836bb811a34
Rust
jorgeja/advent_of_code_2020
/src/day_14/mod.rs
UTF-8
2,537
3.515625
4
[]
no_license
use std::collections::HashMap; fn parse_input(input: &str) -> usize { let mut memory = HashMap::new(); let mut mask = (0, 0); for line in input.lines() { if let Some(index) = line.find("mask = ") { mask = parse_mask(&line[index+7..]); } else if line.starts_with("mem") { ...
true
5a49e9babaae012dfa9f758fb8d4065f191340e7
Rust
scotow/nustify
/examples/image.rs
UTF-8
549
2.515625
3
[ "MIT" ]
permissive
use std::env::args; use std::error::Error; use nustify::notification::Builder; #[tokio::main(flavor = "current_thread")] async fn main() -> Result<(), Box<dyn Error>> { let args = args().skip(1).collect::<Vec<_>>(); let key = args.get(0).ok_or("invalid ifttt key")?; let image = args.get(1).unwrap_or(&"htt...
true
abe0aa3cc8e733c5e72e2ac2696dca3d50c089f9
Rust
mneumann/graph-neighbor-matching
/src/lib.rs
UTF-8
1,100
2.578125
3
[ "MIT" ]
permissive
//! A graph similarity score using neighbor matching according to [this paper][1]. //! //! [1]: http://arxiv.org/abs/1009.5290 "2010, Mladen Nikolic, Measuring Similarity //! of Graph Nodes by Neighbor Matching" //! //! TODO: Introduce EdgeWeight trait to abstract edge weight similarity. pub mod graph; mod graph_...
true
80f28a8ef10c0ee4086e0db03b3bd77c52ad1bf6
Rust
IThawk/rust-project
/rust-master/src/test/ui/span/recursive-type-field.rs
UTF-8
305
2.65625
3
[ "MIT", "LicenseRef-scancode-other-permissive", "Apache-2.0", "BSD-3-Clause", "BSD-2-Clause", "NCSA" ]
permissive
use std::rc::Rc; struct Foo<'a> { //~ ERROR recursive type bar: Bar<'a>, b: Rc<Bar<'a>>, } struct Bar<'a> { //~ ERROR recursive type y: (Foo<'a>, Foo<'a>), z: Option<Bar<'a>>, a: &'a Foo<'a>, c: &'a [Bar<'a>], d: [Bar<'a>; 1], e: Foo<'a>, x: Bar<'a>, } fn main() {}
true
ae5519f20685837d80871500de315a9e5090b7c9
Rust
rushmorem/domain
/src/bits/net/udp.rs
UTF-8
7,589
2.78125
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! Sending and receiving via UDP. use std::{io, mem}; use std::collections::{HashMap, VecDeque}; use std::net::{IpAddr, SocketAddr}; use futures::Async; use futures::stream::Stream; use tokio_core::reactor; use tokio_core::net::UdpSocket; use ::bits::{ComposeMode, MessageBuf}; use super::Flow; use super::mpsc::{Recei...
true
3b246d6ad950edd96365cbfb243c6d9e93a8ae85
Rust
LgnMs/my-leetcode-rust
/dynamic_programming/max_profit.rs
UTF-8
595
3.265625
3
[ "MIT" ]
permissive
/* * @lc app=leetcode.cn id=1 lang=rust * * [121] 买卖股票的最佳时机 * https://leetcode-cn.com/problems/best-time-to-buy-and-sell-stock/ * - [动态规划] */ pub fn max_profit(prices: Vec<i32>) -> i32 { let mut min = prices[0]; let mut max_sum = 0; for x in prices { if x < min { min = x; ...
true
7e659950469db94988ab539be6744acde8d646fa
Rust
DioneJM/minigrep
/src/lib.rs
UTF-8
2,255
3.53125
4
[]
no_license
use std::fs; use std::path::Path; use std::error::Error; pub struct Arguments<'a> { query: &'a String, filename: &'a String, case_sensitive: bool } impl<'a> Arguments<'a> { pub fn new(args: &Vec<String>) -> Result<Arguments, &str> { if args.len() < 3 { return Err("Invalid arguments...
true
d275cbcb6968f76f39f86037ca247b11548bb04e
Rust
hatoo/rukako
/rukako-shader/src/camera.rs
UTF-8
1,966
2.859375
3
[ "MIT" ]
permissive
// use rand::Rng; use spirv_std::glam::Vec3; #[allow(unused_imports)] use spirv_std::num_traits::Float; use crate::math::random_in_unit_disk; use crate::rand::DefaultRng; use crate::ray::Ray; #[derive(Copy, Clone)] pub struct Camera { origin: Vec3, lower_left_corner: Vec3, horizontal: Vec3, vertical: ...
true
53524d00de92ddacf385fbe9e17599a898c28d73
Rust
Junzki/shadowsocks-rust
/src/relay/loadbalancing/server/ping.rs
UTF-8
5,842
2.671875
3
[ "MIT" ]
permissive
use std::io; use std::sync::atomic::{AtomicBool, AtomicU64, Ordering}; use std::sync::Arc; use std::time::{Duration, Instant}; use crate::{ config::ServerConfig, context::SharedContext, relay::loadbalancing::server::LoadBalancer, relay::socks5::Address, relay::tcprelay::client::ServerClient, }; use futures::{...
true
18c5c392f4b1fa1a8e0cb5e2da0ca4acd66485a2
Rust
YuichiroSato/banner-of-life
/src/mold.rs
UTF-8
6,923
3.078125
3
[ "MIT" ]
permissive
use cells::*; use fonts::*; pub struct Mold { pub font_size: usize, pub target: Cells, } impl Mold { pub fn new(font: Font, font_size: usize) -> Self { let mold_scale = font_size as f64 / font.val.len() as f64; let mut cells = Cells::new(font_size, font_size); cells.allocate(Cells:...
true
19bdea239e39e906186270d3e26e99d6af954deb
Rust
cyb0124/OCRemote
/server/RustImpl/src/item.rs
UTF-8
3,797
2.84375
3
[]
no_license
use super::lua_value::{table_remove, Table, Value}; use flexstr::LocalStr; use std::{cmp::min, convert::TryInto, rc::Rc}; #[derive(PartialEq, Eq, Hash)] pub struct Item { pub label: LocalStr, pub name: LocalStr, pub damage: i16, pub max_damage: i16, pub max_size: i32, pub has_tag: bool, pub...
true
ee3b66d3939b7d516edc1adfa2b998975fe8d0b4
Rust
jiegec/pinyin
/src/bin/train.rs
UTF-8
4,126
2.75
3
[]
no_license
extern crate structopt; use encoding_rs::GBK; use pinyin; use serde::Deserialize; use std::collections::{BTreeMap, BTreeSet}; use std::fs::File; use std::io::Read; use std::path::PathBuf; use structopt::StructOpt; #[derive(Debug, Deserialize)] pub struct News { html: String, time: String, title: String, ...
true
76cbef304813c0f5c482c2ce919a76297de8126f
Rust
StevenMeng5898/zCore
/zircon-object/src/signal/futex.rs
UTF-8
4,190
2.890625
3
[ "MIT" ]
permissive
use super::*; use crate::object::*; use alloc::collections::VecDeque; use alloc::sync::Arc; use core::future::Future; use core::pin::Pin; use core::sync::atomic::*; use core::task::{Context, Poll, Waker}; use spin::Mutex; /// A primitive for creating userspace synchronization tools. /// /// ## SYNOPSIS /// A **futex**...
true
50958c3e4ee708e254d48502a8e0be8986f57e5e
Rust
JRud52/Shape_Grammar_Parser
/src/parser.rs
UTF-8
578
3.46875
3
[]
no_license
use lexer::Lexer; use lexer::Token; use lexer::Ident; pub struct Parser { lexer: Lexer, } impl Parser { pub fn new(buffer: String) -> Parser { let lexer = Lexer::new(buffer); Parser {lexer: lexer} } pub fn parse(&mut self){ // loop through the buffer until all the tokens have ...
true
6ffea15c30b2445d837668f9ab3cae8a44be421d
Rust
cptroot/CS11C-to-Rust
/triangle_game.rs
UTF-8
2,601
3.3125
3
[]
no_license
use std::io::println; use triangle_routines::triangle_print; mod triangle_routines; static NUM_PEGS:int = 15; static NUM_MOVES:int = 36; static moves:[[int, ..3], ..NUM_MOVES] = [ [0, 1, 3], [0, 2, 5], [1, 3, 6], [1, 4, 8], [2, 4, 7], [2, 5, 9], [3, 1, 0], [3, 4, 5], [3, 6, 10], [3, 7, 12], [4,...
true
4a743810093d55654d437b127a00846e92f52c54
Rust
jiegec/decaf-rs-pa
/typeck/src/scope_stack.rs
UTF-8
3,304
3.046875
3
[]
no_license
use std::iter; use common::Loc; use syntax::{ScopeOwner, Symbol, ClassDef, Program}; use std::collections::HashMap; pub(crate) struct ScopeStack<'a> { // `global` must be ScopeOwner::Global, but we will not depend on this, so just define it as ScopeOwner global: ScopeOwner<'a>, // ignore symbols whose loc >= ite...
true
437fa7b852ee1c87a38a1f4df0ecab2e63056a42
Rust
imbolc/perseus
/packages/perseus-cli/src/cmd.rs
UTF-8
3,771
3.390625
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use crate::errors::*; use console::Emoji; use indicatif::{ProgressBar, ProgressStyle}; use std::io::Write; use std::path::Path; use std::process::Command; // Some useful emojis pub static SUCCESS: Emoji<'_, '_> = Emoji("✅", "success!"); pub static FAILURE: Emoji<'_, '_> = Emoji("❌", "failed!"); /// Runs the given com...
true
b5ea9e187e8010eeef29cd93e46276d54e8aec4f
Rust
green-s/skim
/src/reader.rs
UTF-8
7,917
3.09375
3
[ "MIT" ]
permissive
///! Reader is used for reading items from datasource (e.g. stdin or command output) ///! ///! After reading in a line, reader will save an item into the pool(items) use crate::field::FieldRange; use crate::item::Item; use crate::options::SkimOptions; use crate::spinlock::SpinLock; use regex::Regex; use std::collection...
true
edcb19c31eea0b027c430d1571f74172d8af1263
Rust
palantir/conjure-rust
/conjure-object/src/bearer_token/mod.rs
UTF-8
5,722
2.78125
3
[ "Apache-2.0" ]
permissive
// Copyright 2018 Palantir Technologies, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or a...
true
64922898e2698e1954014a01a22cbee96af481ad
Rust
alanhoff/rust-v8-experiments
/src/core/communication.rs
UTF-8
1,121
2.578125
3
[ "ISC" ]
permissive
use crate::runtime::Runtime; use std::{future::Future, pin::Pin}; use tokio::sync::mpsc; use std::{cell::RefCell, rc::Rc}; pub type SyncMessage = Box<dyn FnOnce(&Runtime)>; pub type AsyncMessage = Box<dyn FnOnce(&Runtime) -> Pin<Box<dyn Future<Output = ()>>>>; pub struct Channel { pub tx: mpsc::UnboundedSender<As...
true
0d73219a8b572df6557cb4e0140efc564bc74ab6
Rust
sugyan/leetcode
/problems/0946-validate-stack-sequences/lib.rs
UTF-8
958
3.578125
4
[]
no_license
pub struct Solution; impl Solution { pub fn validate_stack_sequences(pushed: Vec<i32>, popped: Vec<i32>) -> bool { let mut stack = Vec::with_capacity(pushed.len()); let mut iter = popped.iter().peekable(); for n in &pushed { stack.push(n); while !stack.is_empty() && ...
true
0a85ffe7d89c46f022dcae1ade88f1d0424da55b
Rust
nerdalert/rust-examples
/json/src/main.rs
UTF-8
1,307
3.109375
3
[ "WTFPL" ]
permissive
#[macro_use] // required for the use of the json! macro on line #26 extern crate serde_json; use serde_json::Value; fn extract(json: &Value, path: String, extracted: &mut Vec<(String, String)>) { match json { Value::String(s) => extracted.push((path, s.clone())), Value::Null => extracted.push((pa...
true
bd5d796deb3e5d1081cb08b0859df15c6c41c4a7
Rust
ecc521/experiments
/char_counter.rs
UTF-8
251
3.34375
3
[]
no_license
use std::io; fn main() { println!("Please input some text"); let mut text = String::new(); io::stdin().read_line(&mut text) .expect("Error reading line"); println!("You input {}", text); println!("That is {} characters", text.len()) }
true
69fec51d504f256861a7409700a3571933c5b28d
Rust
krisprice/playground
/aggip/src/main.rs
UTF-8
709
2.8125
3
[]
no_license
// Created external crate and moved all types and methods there. extern crate ipnet; use ipnet::IpNet; fn main() { let strings = vec![ "10.0.0.0/24", "10.0.1.0/24", "10.0.1.1/24", "10.0.1.2/24", "10.0.2.0/24", "10.1.0.0/24", "10.1.1.0/24", "192.168.0.0/24", "192.168.1.0/24", "192.16...
true
4d8bb77bb0b300cb8f83c7ae8c2fbcceb67fa7d1
Rust
cassandraoconnell/rustdown
/src/document/matchers/selection.rs
UTF-8
2,469
3.5
4
[]
no_license
use super::utils::matcher::{LeftoverString, MatchedString, Matcher, RejectedString}; pub struct SelectionMatcher { selection: Vec<String>, } impl Matcher for SelectionMatcher { fn try_match(&self, input: String) -> Result<(MatchedString, LeftoverString), RejectedString> { let mut unconsumed = String::...
true
bf3739d66c5bf48e2722519142e66bfe9416a8bc
Rust
LordAro/AdventOfCode
/2016/src/bin/day12.rs
UTF-8
2,504
3.21875
3
[]
no_license
use std::collections::HashMap; use std::env; use std::fs::File; use std::io::{BufRead, BufReader}; fn parse_reg(word: &str) -> Option<char> { word.chars().next() } fn run_prog(registers: &mut HashMap<char, i32>, prog: &Vec<Vec<&str>>) { let mut pc = 0; while pc < prog.len() { let ins = &prog[pc]; ...
true
23c6848048de2cfe1522ee919353532a98f5e894
Rust
t3m8ch/another-todolist
/src/models.rs
UTF-8
816
3.265625
3
[ "MIT" ]
permissive
use std::collections::HashMap; use crate::errors::DeleteTodoError; #[derive(Debug)] pub struct Todo { pub title: String, pub body: String } pub struct TodoStore { todos: HashMap<u32, Todo> } impl TodoStore { pub fn new() -> TodoStore { TodoStore { todos: HashMap::new() } } pub f...
true
c1ee946158b78c4265e1f727ed869f3c33bcd0cb
Rust
icodinglife/ouch
/tests/compress_and_decompress.rs
UTF-8
8,281
2.734375
3
[ "MIT" ]
permissive
mod utils; use std::{ env, io::prelude::*, path::{Path, PathBuf}, time::Duration, }; use fs_err as fs; use ouch::{commands::run, Opts, QuestionPolicy, Subcommand}; use rand::{rngs::SmallRng, RngCore, SeedableRng}; use tempfile::NamedTempFile; use utils::*; #[test] /// Makes sure that the files ouch p...
true
77e5ff61cfd80c2fff6b3b47e7d1976e29625251
Rust
cnruby/learn-rust-by-crates
/hello-borrowing/bin-local-hello/examples/usage/main.rs
UTF-8
2,168
2.75
3
[]
no_license
// cargo run --example usage // >> Nothing // cargo run --example usage -- u8_type // cargo run --example usage -- str_type // cargo run --example usage -- references_simple // cargo run --example usage -- ref_and // cargo run --example usage -- string_len_count // cargo run --example usage -- closure // cargo run --ex...
true
4911c7625a3977e5f4e026dab0905c7022e4e807
Rust
mkos11/rserver
/src/main.rs
UTF-8
1,487
3.390625
3
[ "MIT" ]
permissive
mod lib; use std::env; fn main() { /* let us declare default local server host and sever port that will be used in case not all commandline args are passed . */ let (mut server_host, mut server_port) = ("127.0.0.1", 80); // let us add logic to get local server host and sever port from command...
true
075e5835ae94d0bf7d808074519d01b819522284
Rust
lar-rs/can
/src/config.rs
UTF-8
1,011
2.703125
3
[]
no_license
use serde::{Deserialize, Serialize}; use std::io; use std::fs::File; use std::fs; use std::io::prelude::*; // use std::prelude::*; use std::path::Path; use toml; #[derive(Serialize, Deserialize, Clone, Debug)] pub struct Index { pub addr: u32, } /// Configuration #[derive(Serialize, Deserialize, Clone, Debug)]...
true
628a12b59958093682cf7706288477efb8e1e465
Rust
wdhg/game-boy
/src/cpu/instr/instr.rs
UTF-8
1,953
2.90625
3
[ "MIT" ]
permissive
use crate::cpu::instr::operand::{Op16, Op8}; #[derive(Clone, Copy, Debug, PartialEq)] pub enum Instr { NOP, // no operation DAA, // decimal adjust register A CPL, // complement register A (flip all bits) CCF, // complement carry flag SCF, ...
true
c6f63627bfef7ead5a4703c4fd5ef710c31841c8
Rust
Im-Oab/One-Man-ggj21
/src/gameplay/enemy_types/crawling_pop_corn.rs
UTF-8
4,864
2.703125
3
[ "MIT" ]
permissive
use std::collections::HashMap; use std::time::Duration; use rand::prelude::*; use tetra::graphics::{self, Color, GeometryBuilder, Mesh, Rectangle, ShapeStyle}; use tetra::math::Vec2; use tetra::Context; use crate::image_assets::ImageAssets; use crate::sprite::AnimationMultiTextures; use crate::gameplay::enemy_manag...
true
5df7c43b3744f375dab11a20389fd4f3384c0baf
Rust
lanocci/algorithm-and-data-struscture-in-rust
/computational_geometry/geometric_element/src/circle.rs
UTF-8
3,071
3.359375
3
[]
no_license
use std::fmt::Debug; use num_traits::{Float, Zero, cast::FromPrimitive}; use crate::point::{Point, Vector}; use crate::segment::Line; #[derive(Clone, Debug)] pub struct Circle<T> where T: Float + FromPrimitive + Zero { center: Point<T>, radius: T, } impl<T> Circle<T> where T: Float + FromPrimitive + Zero + D...
true
9ff6e00bb5004cb85b0782dfc7c51702c2714367
Rust
RalfJung/miri
/test-cargo-miri/subcrate/main.rs
UTF-8
656
2.8125
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use std::env; use std::path::PathBuf; fn main() { println!("subcrate running"); // CWD should be workspace root, i.e., one level up from crate root. // We have to normalize slashes, as the env var might be set for a different target's conventions. let env_dir = env::current_dir().unwrap(); let env...
true
78cbaa0d7fa510dda30758c21157930fdcc427bf
Rust
wooster0/blockpaint
/src/util.rs
UTF-8
6,460
3.28125
3
[ "MIT" ]
permissive
use crate::{palette, terminal::SIZE}; use std::{convert::TryFrom, fmt, ops}; #[derive(Clone, Debug, Copy, PartialEq)] pub struct Point { pub x: SIZE, pub y: SIZE, } impl Default for Point { fn default() -> Self { Self { x: Default::default(), y: Default::default(), ...
true
cb2259c54fed5622e37546d8c7fe67f0f91fe05e
Rust
ZipFast/lifetime-variance-example
/code/ch01-04-variance-in-practice/simple-message-collector/src/main.rs
UTF-8
1,426
3.421875
3
[ "CC0-1.0" ]
permissive
#![allow(dead_code)] fn main() {} use std::collections::HashSet; use std::fmt; struct Message<'msg> { message: &'msg str, } struct MessageCollector<'a, 'msg> { list: &'a mut Vec<Message<'msg>>, } impl<'a, 'msg> MessageCollector<'a, 'msg> { fn add_message(&mut self, message: Message<'msg>) { self...
true
800ff7c6b620ca111817f030f3c03d7dca2b6214
Rust
uglyoldbob/electronics_design
/src/window/component_name.rs
UTF-8
3,107
2.71875
3
[ "OFL-1.1", "MIT" ]
permissive
//! This window asks the user for a name of the new library use egui_multiwin::egui_glow::EguiGlow; use egui_multiwin::{ egui, multi_window::NewWindowRequest, tracked_window::{RedrawResponse, TrackedWindow}, }; use crate::library::LibraryAction; use crate::MyApp; /// The window structure pub struct Name ...
true
4a62ba56b57f912a15018098afde0fde1e0509bc
Rust
22388o/minimint
/minimint-api/src/outcome.rs
UTF-8
1,519
2.765625
3
[ "MIT" ]
permissive
use crate::SigResponse; use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Eq, PartialEq, Hash, Deserialize, Serialize)] pub enum TransactionStatus { /// The transaction was successfully submitted AwaitingConsensus, /// The error state is only recorded if the error happens after consensus is achie...
true
185eecdfbcd58f95f371ae4b834a1c608d442d9a
Rust
second-super-secret-squirrel-account/rust_tic_tac_toe
/src/player_manager/player/mod.rs
UTF-8
613
3.046875
3
[]
no_license
use game_board::board_token::BoardToken; #[derive(Debug, Eq, PartialEq, Clone)] pub struct Player { player_type: PlayerType, board_token: BoardToken, } #[derive(Debug, Eq, PartialEq, Clone)] pub enum PlayerType { Human, Computer, } impl Player { pub fn new(player_type: PlayerType, board_token: Bo...
true
28af1b1e203cf579b21eba1d5cf7d41ae149dc82
Rust
FaultyPine/SSBU_Twitch_Integration
/src/twitch.rs
UTF-8
5,015
2.8125
3
[]
no_license
use std::{io::BufRead, net::*}; use std::io::*; use crate::{*, utils::*}; /* socket variables */ const SERVER: &str = "34.217.198.238"; // irc.chat.twitch.tv const PORT: u16 = 80; // IRC SPEC: https://tools.ietf.org/html/rfc1459 pub unsafe fn get_chat_msg_info_loop(stream: &mut TcpStream, CHANNEL: String) -> Result<...
true
273bfb2225ddc309e07091823fccab7f863df033
Rust
reitermarkus/heating
/vessel/src/cuboid_tank.rs
UTF-8
1,166
3.53125
4
[]
no_license
use measurements::Length; use measurements::Volume; use crate::level::Level; use crate::tank::Tank; #[derive(Debug)] pub struct CuboidTank { length: Length, width: Length, height: Length, } impl CuboidTank { pub fn new(length: Length, width: Length, height: Length) -> Self { Self { length, width, height ...
true
5397d0cf55f401ee4ce010511550709f598f0cf5
Rust
tamerh/rosalind2
/src/graph/nwc.rs
UTF-8
3,220
2.90625
3
[]
no_license
use petgraph::graph::Graph; use std::collections::{BTreeMap, HashSet}; // slight change of bfs.rs fn negative_weight_cycle(n: usize, edges: Vec<Vec<i32>>, start: usize) -> bool { let mut g = Graph::new(); let mut nodes = BTreeMap::new(); for i in 1..=n { let node = g.add_node(i); nodes.insert(i, node); ...
true
79cfb59a2e16b959cef7e63cda63325f7f7270a2
Rust
mathiasmagnusson/whm
/src/tests.rs
UTF-8
2,733
3.109375
3
[]
no_license
use super::*; #[test] fn factorial() { assert_eq!(0.factorial(), 1); assert_eq!(1.factorial(), 1); assert_eq!(2.factorial(), 2); assert_eq!(3.factorial(), 6); assert_eq!(4.factorial(), 24); assert_eq!(10.factorial(), 3628800); } #[test] fn permutations() { assert_eq!(Integer::permutations(6, 3), 6 * 5 * 4); ass...
true
a5134dd0ba9fd8ebdac3a9855380fd4196e8eb6f
Rust
Disasm/usb-tester
/software/usb-switch-cli/src/device.rs
UTF-8
2,364
2.59375
3
[]
no_license
use std::time::Duration; use libusb::*; use usb_switch_common::{USB_DEVICE_VID, USB_DEVICE_PID, Selection, REQ_SELECT}; use serialport::SerialPortType; pub const TIMEOUT: Duration = Duration::from_secs(1); pub struct DeviceHandles<'a> { pub handle: DeviceHandle<'a>, pub serial_path: String, } impl DeviceHan...
true
e3ccaea7a8dfc1af416f2fd9299f63255c34736e
Rust
dylanaraps/eww-static-test
/src/widgets/mod.rs
UTF-8
6,107
2.625
3
[ "MIT" ]
permissive
use crate::{ config::{element::WidgetDefinition, window_definition::WindowName}, eww_state::*, value::AttrName, }; use anyhow::*; use gtk::prelude::*; use itertools::Itertools; use std::collections::HashMap; use std::process::Command; use widget_definitions::*; pub mod widget_definitions; pub mod widget_n...
true
be56d38fb8dde486b0d105709c1513826af89e8c
Rust
georust/proj
/src/geo_types.rs
UTF-8
11,167
3.140625
3
[ "MIT", "Apache-2.0" ]
permissive
use crate::{Proj, ProjError, Transform}; use geo_types::{coord, Geometry}; ///```rust /// # use approx::assert_relative_eq; /// extern crate proj; /// use proj::Proj; /// use geo_types::coord; /// /// let from = "EPSG:2230"; /// let to = "EPSG:26946"; /// let nad_ft_to_m = Proj::new_known_crs(&from, &to, None).unwrap(...
true
169f2cac28fa49aacc5291b73e23e6f7ce2282af
Rust
ydzz/EternalR
/compiler/src/utils.rs
UTF-8
2,583
2.78125
3
[ "MIT" ]
permissive
use typed_arena::{Arena}; use gluon::base::pos::{BytePos,Span}; use ast::types::{SourceSpan,SourcePos}; pub(crate) trait ArenaExt<T> { fn alloc_fixed<'a, I>(&'a self, iter: I) -> &'a mut [T] where I: IntoIterator<Item = T>, T: Default; } impl<T> ArenaExt<T> for Arena<T> { fn alloc_fixed<'a...
true
4f8d396bb7737637a40860b2472338e5e08c1b3a
Rust
intendednull/yew
/examples/boids/src/slider.rs
UTF-8
2,536
2.953125
3
[ "Apache-2.0", "MIT" ]
permissive
use std::cell::Cell; use yew::{html, Callback, Component, ComponentLink, Html, InputData, Properties, ShouldRender}; thread_local! { static SLIDER_ID: Cell<usize> = Cell::default(); } fn next_slider_id() -> usize { SLIDER_ID.with(|cell| cell.replace(cell.get() + 1)) } #[derive(Clone, Debug, PartialEq, Propert...
true
fe1ec5b8d830a5a3ad6ec719c252e29003b99774
Rust
hekarusindo/pumltestrust
/src/main.rs
UTF-8
6,851
2.84375
3
[ "MIT" ]
permissive
use std::env; use std::fs; use c_lexer; use c_lexer::token::Token::*; use c_lexer::token::Token; //TODO do while, if else without {},switch, bug fix fn main() { let args: Vec<String> = env::args().collect(); let path = args[1].to_string(); let _output = args[1].to_string(); let code = fs::read_to_strin...
true
a25f9336eaf8f602c2b79f10b3205ff8b6fa6fd2
Rust
21eleven/leetcode-solutions
/rust/1342_number_of_steps_to_reduce_a_number_to_zero/sim.rs
UTF-8
1,223
3.75
4
[]
no_license
/* 1342. Number of Steps to Reduce a Number to Zero Easy Given a non-negative integer num, return the number of steps to reduce it to zero. If the current number is even, you have to divide it by 2, otherwise, you have to subtract 1 from it. Example 1: Input: num = 14 Output: 6 Explanation: Step 1) 14 is even; d...
true
6cf2d38ed4106f636e08c48ca290475d786c6770
Rust
tlafebre/address_book
/src/db.rs
UTF-8
2,137
2.890625
3
[]
no_license
extern crate rusqlite; use rusqlite::{params, Connection, Error, Result}; use std::path::PathBuf; use super::contact; use contact::Contact; #[derive(Debug)] pub struct Database { pub path: PathBuf, } impl Database { pub fn create_table(&self) -> Result<()> { let conn = self.connect()?; conn...
true
84f3092247bfbccce0c016cde0b7961b576dd4eb
Rust
AbsoluteVirtueXI/api-test
/src/bin/routing.rs
UTF-8
2,118
2.96875
3
[]
no_license
#![deny(warnings)] use warp::Filter; use serde::{Deserialize}; #[derive(Deserialize)] struct SumQuery { left: u32, right: u32, } #[tokio::main] async fn main() { let sumquery = warp::path("sumquery") .and(warp::query::<SumQuery>()) .and(warp::path::end()) .map(|sum_query: SumQue...
true
015552cc805c4711cd6aadea2d4adef1f3591669
Rust
fluxxu/actix-web-async-compat
/src/lib.rs
UTF-8
981
2.796875
3
[]
no_license
//! Actix web 1.x async/await shim. use futures::{self, compat::Compat, FutureExt, TryFutureExt}; use std::pin::Pin; /// Convert a async fn into a actix-web handler. /// /// ```rust /// use actix_web::{web, App, HttpResponse, Error}; /// use std::time::{Instant, Duration}; /// use tokio::timer::Delay; /// use actix_w...
true
0f9b95ad1a2c8dbb9aa0f5db5712f519314c1d07
Rust
7e4/himalaya
/src/domain/msg/flag_arg.rs
UTF-8
3,278
3.296875
3
[]
no_license
//! Message flag CLI module. //! //! This module provides subcommands, arguments and a command matcher related to the message flag //! domain. use anyhow::Result; use clap::{self, App, AppSettings, Arg, ArgMatches, SubCommand}; use log::{debug, trace}; use crate::domain::msg::msg_arg; type SeqRange<'a> = &'a str; ty...
true
8bca9c6ca31b3ca0738bb958f37ece1aa3f3a4a8
Rust
isgasho/dialectic
/dialectic/src/types/split.rs
UTF-8
1,935
2.90625
3
[ "MIT" ]
permissive
use std::{any::Any, marker::PhantomData}; use super::sealed::IsSession; use super::*; /// Split the connection into send-only and receive-only halves using [`split`](crate::Chan::split). /// /// The type `Split<P, Q, R>` means: do the [`Transmit`](crate::backend::Transmit)-only session `P` /// concurrently with the [...
true
68bee3340c94ee7db2e817ff5695a45dba9120cb
Rust
UkolovaOlga/rust-lnpbp
/src/rgb/stash/stash.rs
UTF-8
6,214
2.578125
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
// LNP/BP Rust Library // Written in 2020 by // Dr. Maxim Orlovsky <orlovsky@pandoracore.com> // // To the extent possible under law, the author(s) have dedicated all // copyright and related and neighboring rights to this software to // the public domain worldwide. This software is distributed without // any warra...
true
a01064badedc9cda72a89eb329902db05e21c258
Rust
sunng87/tower-web
/src/response/context.rs
UTF-8
1,796
3.0625
3
[ "MIT" ]
permissive
use response::{Serializer, ContentType}; use bytes::Bytes; use http::header::HeaderValue; use serde::Serialize; /// Context available when serializing the response. #[derive(Debug)] pub struct Context<'a, S: Serializer + 'a> { serializer: &'a S, default_content_type: Option<&'a ContentType<S::Format>>, } imp...
true
d272c81c196848c6c3899da60cbba959493886bf
Rust
sandmor/moving
/src/dpi.rs
UTF-8
1,150
3.203125
3
[ "MIT" ]
permissive
#[derive(Debug, Copy, Clone, PartialOrd, PartialEq)] pub struct LogicalSize { pub w: f64, pub h: f64, } impl LogicalSize { pub fn width(&self) -> f64 { self.w } pub fn height(&self) -> f64 { self.h } pub fn from_physical(physical: PhysicalSize, dpi: Dpi) -> Self { ...
true
f460259a920a8f0cb542fc150d1bcd0b7af2a355
Rust
songlinshu/win-crypto-ng
/src/symmetric.rs
UTF-8
20,592
3.328125
3
[ "BSD-3-Clause", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! Symmetric encryption algorithms //! //! Symmetric encryption algorithms uses the same key (the shared-secret) to encrypt and decrypt the //! data. It is usually more performant and secure to use this type of encryption than using //! asymmetric encryption algorithms. //! //! # Usage //! //! The first step is to cre...
true
50f48d49448a13081acc3f339d6206cda4dfe035
Rust
slerpyyy/ndi-rs
/ndi/src/send.rs
UTF-8
8,969
3.28125
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use super::*; use std::{convert::TryFrom, ffi::CString, mem::MaybeUninit}; /// Builder struct for [`Send`] #[derive(Debug, Clone)] pub struct SendBuilder { ndi_name: Option<String>, groups: Option<String>, clock_video: Option<bool>, clock_audio: Option<bool>, } impl SendBuilder { /// Create new bu...
true