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
f7988d7c45468f9c3313152682abef6ccaf265e5
Rust
svenschmidt75/Rust
/Playground/Raytracer/primitives/src/Material.rs
UTF-8
215
2.546875
3
[]
no_license
use crate::Ray::Ray; use crate::Vector4f::Vector4f; use crate::Vertex4f::Vertex4f; pub trait Material { fn scatter(&self, ray: &Ray, intersection_point: Vertex4f, normal: Vector4f) -> Option<(Ray, Vector4f)>; }
true
a8941a27631e3c8aa146893dfb6cd5fc0d933328
Rust
Gabriel4256/rv6-benchmark-backup
/kernel-rs/src/bio.rs
UTF-8
5,265
3.03125
3
[ "MIT" ]
permissive
//! Buffer cache. //! //! The buffer cache is a linked list of buf structures holding cached copies of disk block //! contents. Caching disk blocks in memory reduces the number of disk reads and also provides a //! synchronization point for disk blocks used by multiple processes. //! //! Interface: //! * To get a buff...
true
ec3c91591055716acf679a738e2e6e85bd76bcf0
Rust
Globidev/advent-of-code
/2015/rust/src/day17.rs
UTF-8
1,645
3.15625
3
[]
no_license
type Container = u32; fn combinations(sum: u32, containers: Vec<Container>, so_far: Vec<Container>) -> Vec<Vec<Container>> { use std::cmp::Ordering::{Less, Equal}; let mut all = Vec::new(); let new_combination = |container| { let mut combination = so_far.clone(); combination.push(containe...
true
93b193d21dac4084998f78f6fda59207cc381315
Rust
omprakashsridharan/tote
/src/model.rs
UTF-8
174
2.53125
3
[]
no_license
#[derive(Debug)] pub struct Tote { pub id: i32, pub note: String, pub created_at: mysql::chrono::NaiveDateTime, pub updated_at: mysql::chrono::NaiveDateTime }
true
055210e4d79f6adaefde0f798a604f0f069e9343
Rust
ric2b/Vivaldi-browser
/chromium/third_party/rust/supports_color/v1/crate/src/lib.rs
UTF-8
5,979
3.015625
3
[ "BSD-3-Clause", "Apache-2.0", "LGPL-2.0-or-later", "MIT", "GPL-1.0-or-later" ]
permissive
//! Detects whether a terminal supports color, and gives details about that //! support. It takes into account the `NO_COLOR` environment variable. //! //! This crate is a Rust port of [@sindresorhus](https://github.com/sindresorhus)' //! [NPM package by the same name](https://npm.im/supports-color). //! //! ## Example...
true
dab828f78ff75fd3ecf0c076572325586573d413
Rust
sky0621/study-rust
/rust-by-example/old/ch15b/src/main.rs
UTF-8
358
3.328125
3
[]
no_license
fn main() { let x: i32 = 3; borrow(&x); borrow(&x); borrow(&x); cp(x); cp(x); cp(x); let bx = Box::new(x); eat(bx); eat2(&bx); } fn borrow(b: &i32) { println!("{}", b); } fn cp(c: i32) { println!("{}", c); } fn eat(e: Box<i32>) { println!("{}", e); } fn eat2(e: ...
true
85a7186ff6103717a3fcfda029d627f9ca492c51
Rust
marco-c/gecko-dev-wordified
/third_party/rust/futures-util/src/io/cursor.rs
UTF-8
6,671
3.34375
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
use futures_core : : task : : { Context Poll } ; use futures_io : : { AsyncBufRead AsyncRead AsyncSeek AsyncWrite IoSlice IoSliceMut SeekFrom } ; use std : : io ; use std : : pin : : Pin ; / / / A Cursor wraps an in - memory buffer and provides it with a / / / [ AsyncSeek ] implementation . / / / / / / Cursor s are use...
true
337b367584b651edb9eab64994231fcbdef59f84
Rust
noelzubin/revise
/src/main.rs
UTF-8
822
2.640625
3
[]
no_license
mod conductor; mod error; mod sm2; mod store; use conductor::Conductor; use store::ID; use structopt::StructOpt; #[derive(StructOpt)] enum Opt { Add { desc: String }, Edit { id: ID, desc: String }, View { id: ID }, Remove { id: ID }, Review { id: Option<ID> }, List { qry: Option<String> }, } ...
true
a44d10abee61392a1054afe086c8b4569aad79bc
Rust
destenson/dwrensha--seer
/src/memory.rs
UTF-8
59,701
2.796875
3
[ "Apache-2.0", "MIT" ]
permissive
use byteorder::{ReadBytesExt, WriteBytesExt, LittleEndian, BigEndian}; use std::collections::{btree_map, BTreeMap, HashMap, HashSet, VecDeque, BTreeSet}; use std::{fmt, iter, ptr, mem, io}; use rustc::{ty, mir}; use rustc::ty::layout::{self, HasDataLayout, TargetDataLayout}; use rustc::mir::interpret::{AllocType}; us...
true
d92273b15f88ed803bf6ff780f4445d04ea2f2bd
Rust
msmousehome/expectrl
/examples/powershell.rs
UTF-8
1,403
2.546875
3
[ "MIT" ]
permissive
#[cfg(windows)] fn main() { use expectrl::{repl::spawn_powershell, ControlCode, Regex}; let mut p = spawn_powershell().unwrap(); // case 1: execute let hostname = p.execute("hostname").unwrap(); println!( "Current hostname: {:?}", String::from_utf8(hostname).unwrap() ); //...
true
cf38b9d7c135a94f74422f493d834e3b42d3aefa
Rust
gijs-s/pointctl
/src/filesystem/csv.rs
UTF-8
3,807
3.5
4
[ "MIT" ]
permissive
//! A small helper for reading and writing CSV files without headers // // TODO: use nom instead of of manual stuff. use std::fs::File; use std::io::{prelude::*, BufReader, BufWriter}; use std::path::Path; use std::process::exit; use crate::util::types::PointN; pub fn write(file_path: &Path, points: Vec<PointN>) -> ...
true
dfc988ff1f6dccf1cfa68fa025dc50a65e76cfb4
Rust
arturocs/game_of_life
/src/main.rs
UTF-8
4,431
2.890625
3
[]
no_license
use std::time::{Duration, Instant}; use rand::{thread_rng, Rng}; use speedy2d::{ color::Color, dimen::Vector2, shape::Rectangle, window::{KeyScancode, MouseButton, VirtualKeyCode, WindowHandler, WindowHelper}, Graphics2D, Window, }; const BOARD_SIZE: Vector2<usize> = Vector2::new(128, 72); const C...
true
f202e2ddf5a9a421b0f41aacaf63bbb3e6c09bf8
Rust
alanthinker/Pleco
/pleco/src/core/move_list.rs
UTF-8
15,484
3.578125
4
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! Contains the `MoveList` & `ScoreMoveList` structures, akin to a `Vec<BitMove>` but faster for //! our purposes. //! //! A [`MoveList`] structure is guaranteed to be exactly 512 bytes long, containing a maximum of 256 //! moves. This number was chosen as no possible chess position has been found to contain more than...
true
2fe4bd32315ebb742504a00920c89819a338c0a3
Rust
spyqqqdia/convopt
/src/error/mod.rs
UTF-8
1,571
2.90625
3
[]
no_license
use std::{error::Error, fmt}; use std::fmt::{Debug, Formatter, Display}; /// Possible errors occurring in this library. #[derive(Debug, Clone)] pub struct ConvOptError { pub kind: ErrKind, } #[derive(Debug, Clone)] pub enum ErrKind { BackSolveFailure(&'static str), ForwardSolveFailure(&'static str), ...
true
392b8c7728fb69826821c91a8909ed2126eaf875
Rust
exercism/rust
/exercises/practice/series/tests/series.rs
UTF-8
780
3.140625
3
[ "MIT" ]
permissive
use series::*; #[test] fn test_with_zero_length() { let expected = vec!["".to_string(); 6]; assert_eq!(series("92017", 0), expected); } #[test] #[ignore] fn test_with_length_2() { let expected = vec![ "92".to_string(), "20".to_string(), "01".to_string(), "17".to_string(), ...
true
73ac1cf2869f6b6be969c912c1074f680e35a5d7
Rust
cberzan/aoc-2018
/03/solve/src/main.rs
UTF-8
5,155
3.171875
3
[]
no_license
#[macro_use] extern crate lazy_static; extern crate regex; use regex::Regex; use std::collections::HashSet; use std::io; #[derive(Debug)] #[derive(PartialEq)] struct Claim { id: i32, start_row: usize, start_col: usize, num_rows: usize, num_cols: usize, } // Parses a claim from a string. fn parse_...
true
1b018fb44684ec6596c7e7089a1424d127ef4370
Rust
CarlEkerot/gameboy
/src/instructions.rs
UTF-8
1,870
3.28125
3
[]
no_license
use std::fmt; use definition::{Definition, Operand}; use errors::*; #[derive(Debug, Clone)] pub struct Instruction { pub definition: &'static Definition, pub immediate: Option<u16>, } impl Instruction { pub fn get_immediate_usize(&self) -> Result<usize> { self.immediate.map(|i| i as usize).chain_e...
true
70c64d10811e04f15155f332f6c0c06211cce3d0
Rust
Vinatorul/tileengine-rs
/src/layer.rs
UTF-8
2,552
3.109375
3
[ "MIT" ]
permissive
use chunk::Chunk; use tile::Tile; use std::collections::HashMap; const DEF_CHUNK_WIDTH: i32 = 100; const DEF_CHUNK_HEIGHT: i32 = 100; pub struct TilesLayer<T> { x_offset: i32, y_offset: i32, chunks: Vec<Chunk<T>>, } impl<T> TilesLayer<T> { pub fn new() -> TilesLayer<T> { TilesLayer { ...
true
a6ba358b548a01ea4657e995a6ee10fbc74c5b49
Rust
faim-lab/mappy
/batch/src/main.rs
UTF-8
1,793
2.625
3
[]
no_license
use mappy::MappyState; use retro_rs::{Buttons, Emulator, FramebufferToImageBuffer}; use std::path::Path; use std::time::Instant; fn main() { use std::env; let args: Vec<_> = env::args().collect(); let mut emu = Emulator::create( Path::new("cores/fceumm_libretro"), Path::new(args[1].as_str())...
true
15fc6899c439c3d0e61c5630f58930894a52f6c3
Rust
ummarikar/yksom
/src/lib/vm/objects/string_.rs
UTF-8
2,175
3
3
[ "MIT", "Apache-2.0" ]
permissive
#![allow(clippy::new_ret_no_self)] use std::str; use abgc_derive::GcLayout; use crate::vm::{ core::{VMError, VM}, objects::{Obj, ObjType, StaticObjType}, val::{NotUnboxable, Val}, }; #[derive(Debug, GcLayout)] pub struct String_ { s: String, is_str: bool, } impl Obj for String_ { fn dyn_obj...
true
dfb8f8d4d066183d927886acfe138862ce25cd32
Rust
tikaradate/chip8
/src/cpu.rs
UTF-8
12,766
3.171875
3
[]
no_license
use rand::Rng; use std::fs; pub struct Chip8 { pub opcode: usize, memory: [usize; 4096], reg: [usize; 16], pc: usize, index: usize, pub delay_timer: usize, pub sound_timer: usize, stack: [usize; 16], sp: usize, pub key: [bool; 16], pub gfx: [bool; 64 * 32], // internal f...
true
580601929b26024c5872670e9c010890d21a920d
Rust
grahamc/security
/lwnvulns/src/bin/new.rs
UTF-8
5,605
2.65625
3
[ "MIT" ]
permissive
extern crate lwnvulns; extern crate scraper; extern crate curl; use lwnvulns::tokenize::{tokenize, Token, Header, Issue, SourceLink}; use lwnvulns::parse::parse; use lwnvulns::writer::write; use lwnvulns::transform::collapse_anemic; use scraper::{Html, Selector}; use curl::easy::Easy; use std::io::{Read, Write}; use ...
true
214c74182880823418b0889a0fac0d79c7ff388f
Rust
tedbyron/rust-challenges
/src/math/lists/min_value.rs
UTF-8
299
3.359375
3
[]
no_license
//! given a list of digits, return the smallest number that could be formed from //! these digits, using the digits only once #[allow(dead_code)] pub fn min_value(mut digits: Vec<i32>) -> i32 { digits.sort_unstable(); digits.dedup(); digits.into_iter().fold(0, |acc, d| acc * 10 + d) }
true
ed4b83eef8d6c94dbc35137bf6bd825a712a0ea8
Rust
nox/clipboard-win
/tests/clipboard.rs
UTF-8
3,452
2.8125
3
[ "MIT" ]
permissive
extern crate clipboard_win; use clipboard_win::*; use clipboard_win::wrapper::{open_clipboard, close_clipboard, set_clipboard_raw, get_clipboard_seq_num}; //NOTE: parallel running may cause fail. #[test] fn win_error_test() { //check PartialEq assert!(WindowsError::new(0) == 0 as u16); assert!...
true
c708b61cf185be2f00474b7e5d90651b0146e0d3
Rust
triglav/advent_of_code
/2022/day08/src/main.rs
UTF-8
3,638
3.234375
3
[ "MIT" ]
permissive
use std::{collections::HashSet, io}; type Grid = Vec<Vec<i8>>; #[derive(PartialEq, Eq, Hash)] struct Coord { x: usize, y: usize, } fn read_grid() -> Grid { let mut grid = Grid::new(); for line in io::stdin().lines().map(|l| l.unwrap()) { let mut v = Vec::new(); for c in line.chars() {...
true
841831665ce9a7764bdb3551554c422c4a0b3cbf
Rust
slayerwalt/LeetCode
/OJ/leet918/src/main.rs
UTF-8
959
2.84375
3
[]
no_license
// leet918 #![allow(dead_code)] #![allow(non_snake_case)] #![allow(unused_variables)] // #![allow(unused_mut)] #![allow(unused_macros)] #![allow(unused_imports)] struct Solution; use std::collections::HashMap; use std::cmp::max; use std::cmp::min; macro_rules! vec_of_strings { ($($x:expr),*) => (v...
true
92e872844f186648936c80d02f5f3415c2ae40fe
Rust
iCodeIN/mina-rs
/consensus/src/common.rs
UTF-8
6,133
2.671875
3
[ "Apache-2.0" ]
permissive
// Copyright 2020 ChainSafe Systems // SPDX-License-Identifier: Apache-2.0 use hex::ToHex; use mina_crypto::hash::{Hashable, StateHash}; use mina_rs_base::consensus_state::ConsensusState; use mina_rs_base::global_slot::GlobalSlot; use mina_rs_base::protocol_state::{Header, ProtocolState}; use thiserror::Error; pub st...
true
21266892d0665949e3301f4ca6c53066fa4aecf0
Rust
a186r/rust
/day07/rust_iterator/src/main.rs
UTF-8
1,873
4.28125
4
[]
no_license
fn main() { // let v1 = vec![1,2,3,4]; // let v1_iter = v1.iter(); // for val in v1_iter { // println!("Got: {}",val); // } // 调用迭代器适配器map来创建一个新迭代器. // let v1: Vec<i32> = vec![1,2,3]; // v1.iter().map(|x| x + 1); // -------------------------------------------产生迭代器的方法 l...
true
fd3866cd16320ba03e8d8fd6a24a8874c398fb9a
Rust
Succo/aoc2018
/day2Star1/src/main.rs
UTF-8
916
3.46875
3
[]
no_license
use std::collections::HashMap; use std::fs::File; use std::io::BufReader; use std::io::prelude::*; fn main() -> std::io::Result<()> { let file = File::open("input")?; let buf_reader = BufReader::new(file); let lines = buf_reader.lines().map(|l| count_letters(&l.unwrap())); let sum :(u32, u32) =lines.f...
true
36b95de5ce59b843becd078a3ad1e3ebb3d9e653
Rust
killer-mushroom-collective/katas
/rapier_physics_2d/src/main.rs
UTF-8
3,074
2.8125
3
[ "MIT" ]
permissive
use bevy::prelude::*; use bevy_rapier2d::prelude::*; // TODO Resolve this https://rapier.rs/docs/user_guides/rust_bevy_plugin/common_mistakes#why-is-everything-moving-in-slow-motion fn main() { App::build() .add_startup_system(setup_camera.system()) .add_startup_system(setup_materials.system()) ...
true
3cb3ddb56e61e1ba9e8cdbdcf3691310d96bc511
Rust
phaylon/textkind
/src/kind.rs
UTF-8
1,630
3.4375
3
[ "MIT" ]
permissive
//! Predefined text kinds. //! //! It is proably more convenient to use the text type aliases exported from the top level //! instead of directly using these kinds. That way it is possible to say `Title<String>` //! instead of `Text<Title, String>`. //! //! See the `check` module for predefined check types. //! //! See...
true
e45fd4710cd0e78d847b834b9f5bcf86454acee8
Rust
eqlabs/pathfinder
/crates/stark_poseidon/build.rs
UTF-8
6,418
2.6875
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
use num_bigint::BigUint; use stark_curve::FieldElement; use std::fmt::Write; use std::fs::File; use std::io::{self, BufRead}; use std::str::FromStr; use std::{env, fs, path::Path}; const FULL_ROUNDS: usize = 8; const PARTIAL_ROUNDS: usize = 83; /// Generates poseidon_consts.rs pub fn main() { let manifest_dir = e...
true
a4446332e0a05510bc5f7f867dd6b3d9a21c0089
Rust
xpeerchain/xpeerchain
/language/vm/vm_runtime/src/value.rs
UTF-8
14,608
2.6875
3
[ "Apache-2.0" ]
permissive
// Copyright (c) The XPeer Core Contributors // SPDX-License-Identifier: Apache-2.0 use crate::loaded_data::{struct_def::StructDef, types::Type}; use std::{ cell::{Ref, RefCell}, rc::Rc, }; use types::{ access_path::AccessPath, account_address::{AccountAddress, ADDRESS_LENGTH}, byte_array::ByteArra...
true
cd6042e8165e7cce3202a178b34f8aa8e2221584
Rust
g2xpf/future-map-practice
/src/spin_runner.rs
UTF-8
1,009
2.546875
3
[]
no_license
use super::spin_waker::SpinWaker; use std::future::Future; use std::ops::{Deref, DerefMut}; use std::pin::Pin; use std::task::{Context, Poll}; pub struct SpinRunner; impl SpinRunner { pub fn new() -> Self { Self } pub fn run<F>(&mut self, future: F) -> F::Output where F: Future, {...
true
2d472ee42471b58fea0cdfb45abe9b8f9c8bed77
Rust
ludegra/linear-algebra-in-rust
/src/matrix/matrix4.rs
UTF-8
9,782
3.09375
3
[]
no_license
use super::Matrix; use crate::vector::{Vector, Vector3, Vector4}; use crate::vector::{ToVector3}; use crate::utils::Pad; use num_traits::Num; use std::ops::{Add, Mul, Sub, Index, IndexMut}; use std::fmt::{Display, Formatter}; use super::Matrix4; impl<T> Matrix4<T> where T: Num + Copy { pub fn new(values: [[T...
true
5fca72f41eb4e21d2c83573b64c3ce2aaff23ed9
Rust
localghost/membership
/src/incoming_message.rs
UTF-8
1,116
2.59375
3
[ "Apache-2.0" ]
permissive
#![deny(missing_docs)] use crate::member::Member; use crate::notification::Notification; #[derive(Debug)] pub(crate) struct DisseminationMessageIn { pub(crate) sender: Member, pub(crate) sequence_number: u64, pub(crate) notifications: Vec<Notification>, pub(crate) broadcast: Vec<Member>, } #[derive(D...
true
93e7b62a2a10b7392d2b016f10d6362f4ca36eef
Rust
BLAKE3-team/BLAKE3-specs
/benchmarks/thread_benches/benches/bench.rs
UTF-8
4,264
2.796875
3
[ "CC0-1.0", "Apache-2.0", "LicenseRef-scancode-public-domain" ]
permissive
use criterion::{criterion_group, criterion_main, Criterion, ParameterizedBenchmark, Throughput}; use rand::prelude::*; const MIN_LEN: usize = 1 << 15; const MAX_LEN: usize = 1 << 30; criterion_group!(cg, benchmarks); criterion_main!(cg); fn hash_rayon(input: &[u8]) -> blake3::Hash { blake3::Hasher::new() ...
true
af819a33e0b651fd56b02031aef5f73a7d343a85
Rust
jphjsoares/rshell
/src/commands.rs
UTF-8
3,649
3.4375
3
[]
no_license
use std::process; use std::env; use std::io::prelude::*; use std::fs::File; use std::path::Path; use std::fs; use crate::utils::debug; pub fn builtin_help() -> i32 { println!("Implemented commands:\n"); println!("echo"); println!("exit"); println!("cat"); println!("pwd"); println!("rm"); ...
true
432cf35fb693124d4ff2029dc9078c0840879fde
Rust
hortonhearsadan/f1-telemetry-rs
/f1-telemetry-display/src/ui/fmt.rs
UTF-8
2,255
2.640625
3
[ "MIT" ]
permissive
const TEAM_COLOUR_OFFSET: i16 = 100; const STATUS_COLOUR_OFFSET: i16 = 200; use f1_telemetry::packet::participants::Team; use ncurses::*; #[derive(Debug, Clone, Copy, Eq, PartialEq)] pub enum Status { OK = (STATUS_COLOUR_OFFSET + 1) as isize, CAUTION = (STATUS_COLOUR_OFFSET + 2) as isize, WARNING = (STATU...
true
c39e89e5af24b1fe4e400b9b7173575e50cfd8c9
Rust
ricmzn/dcs-hemmecs
/src/config.rs
UTF-8
3,321
3.015625
3
[ "MIT" ]
permissive
use anyhow::{Context, Result}; use serde::{Deserialize, Serialize}; use std::fs::{rename, File}; use std::io::{ErrorKind, Read, Write}; use std::sync::{Arc, Mutex}; use crate::consts::CONFIG_FILE; #[derive(Clone, Serialize, Deserialize)] #[serde(default)] #[doc = "docs"] pub struct Occlusion { pub hide_on_hud: bo...
true
0a50ce385cd7e827979994731e53d01cde198808
Rust
hanxueming126/raft-engine
/src/util.rs
UTF-8
9,284
2.703125
3
[ "Apache-2.0" ]
permissive
// Copyright (c) 2017-present, PingCAP, Inc. Licensed under Apache-2.0. use std::collections::{HashMap as StdHashMap, VecDeque}; use std::fmt::{self, Display, Write}; use std::hash::BuildHasherDefault; use std::ops::{Div, Mul}; use std::str::FromStr; use std::time::{Duration, Instant}; use crc32fast::Hasher; use serd...
true
f9600ef5fe54223642af1ba441746eba54918e89
Rust
basiliqio/sppparse
/sppparse/src/sparse_selector.rs
UTF-8
3,978
3.140625
3
[ "MIT" ]
permissive
use super::*; use serde::{Deserialize, Serialize}; use std::any::Any; /// # An owned selector between a raw object, a raw pointer or an owned pointer /// /// Use this enum in your structure when allowing either a pointer or the value directly. /// /// The [SparseSelector](SparseSelector) allows to switch between a raw...
true
6682216da868990dcee0ddc6a3cac4ff6971d572
Rust
tormol/nbstr
/src/shared.rs
UTF-8
10,212
3.0625
3
[ "Apache-2.0" ]
permissive
/* Copyright 2016 Torbjørn Birch Moltu * * 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 agre...
true
1cae787b842c4156d80b64fd38ecc3333597371d
Rust
Adam-Jimenez/advent-of-code-2019-rust
/src/level6/mod.rs
UTF-8
2,431
3.09375
3
[]
no_license
use std::collections::{HashMap, HashSet}; use std::iter::FromIterator; use std::fs::File; use std::io::{self, BufReader}; use std::io::prelude::*; use std::error::Error; fn parse_input(file: &str) -> Result<HashMap<String, Vec<String>>, Box<dyn Error>> { let mut map = HashMap::new(); let f = File::open(file)?...
true
6c8179df92c1e8de1f58909a31f17f4f292b727c
Rust
scalefactory/s3du
/src/common/human_size.rs
UTF-8
1,441
3.421875
3
[ "Apache-2.0", "MIT" ]
permissive
// HumanSize trait and implementations #![forbid(unsafe_code)] #![deny(missing_docs)] use humansize::format_size; use super::SizeUnit; use tracing::debug; /// `HumanSize` trait. pub trait HumanSize { fn humansize(&self, unit: &SizeUnit) -> String; } /// `HumanSize` trait implementation for `usize`. impl HumanSize...
true
2be859783872a1e1d1a500db811b76ada64561cf
Rust
SetTheorist/rust-special-functions
/sf_impl/src/poly.rs
UTF-8
5,902
3.28125
3
[ "BSD-3-Clause" ]
permissive
use std::ops::{Add, Div, Mul, Neg, Sub}; use std::ops::{AddAssign, DivAssign, MulAssign, SubAssign}; use crate::traits::*; // TODO: this is a mess, disorganized and inefficient #[derive(Clone, Debug)] pub struct Poly<T>(pub Vec<T>); impl<T: Zero> Poly<T> { pub fn x(&self, n: usize) -> Poly<T> { let mut res = ...
true
f50d9fe67f89012e19b9a313cb0dcc938fb7c576
Rust
BruParis/kvs
/src/bin/kvs-server.rs
UTF-8
2,570
2.578125
3
[]
no_license
#[macro_use] extern crate clap; #[macro_use] extern crate slog; extern crate slog_async; extern crate slog_term; use clap::App; use kvs::{KVServer, KVStore, Result, SledKVEngine}; use slog::{Drain, Logger}; use std::process; // use hello_web_server::ThreadPool; enum Engine { Kvs, Sled, } fn main() -> Resul...
true
480abad241cc7bfaaba297b26ab48aef824790c8
Rust
sile/euler.rs
/euler_01/src/problem042.rs
UTF-8
669
3.171875
3
[]
no_license
//! [42] Coded triangle numbers //! --------------------------- //! //! https://projecteuler.net/problem=42 //! use euler_lib::utils; use std::collections::HashSet; use std::iter::FromIterator; pub fn solve() -> u64 { let words = utils::load_names("data/p042_names.txt"); let values: Vec<_> = words.iter().map(|...
true
b8105b7f13dd50606d4139041bf0b0f788848023
Rust
fitzgen/peepmatic
/crates/runtime/src/integer_interner.rs
UTF-8
2,078
3.5625
4
[]
no_license
//! Interner for (potentially large) integer values. //! //! We support matching on integers that can be represented by `u64`, but only //! support automata results that fit in a `u32`. So we intern the (relatively //! few compared to the full range of `u64`) integers we are matching against //! here and then reference...
true
3844f6f7d8f64b6f4a3c1617b52c520ad40206c9
Rust
orottier/text-index
/src/index.rs
UTF-8
2,947
3.015625
3
[]
no_license
use crate::csv_index::CsvIndexType; use crate::csv_reader::CsvReader; use log::{debug, info, trace}; use std::time::Instant; use std::error::Error; use std::fs::File; use std::sync::{Arc, Mutex}; use std::thread; pub fn index( filename: &str, column: usize, csv_type: &str, threads: u64, ) -> Result<...
true
93a410bb65e60d1e1bfa4ea8905f1ce6603a3ca1
Rust
alexjavabraz/stressTestApi
/src/createAccount.rs
UTF-8
1,890
3.09375
3
[]
no_license
#[macro_use] use reqwest::Error; use rand::Rng; use reqwest::Client; #[derive(Deserialize, Debug)] struct User { phoneNumber: String, cpf: String, name: String, deviceId: String } pub fn call_api(current: i32) -> Result<(), Error> { println!("Create Account - Current Thread {:?}", current); ...
true
c2cfff0fd9c5fb0a6bfccc8b34cf994bdc0a03ca
Rust
tbremer/adventofcode
/2015/02/src/main.rs
UTF-8
2,132
3.484375
3
[]
no_license
#[derive(Debug)] struct Present { w: u32, h: u32, l: u32, } impl Present { fn two_smallest_sides(&self) -> (u32, u32) { let mut a = vec![self.w, self.h, self.l]; a.sort(); (a[0], a[1]) // (0, 0) } pub fn from_str(str: &str) -> Present { let parsed_dimen...
true
4ed5b9a537f3ec328249609e65bdf26d388fa6bd
Rust
jeffomatic/nes
/src/cpu/opcode.rs
UTF-8
29,972
3.515625
4
[]
no_license
use super::address_mode::AddressMode; use std::collections::{HashMap, HashSet}; // Reference: http://obelisk.me.uk/6502/reference.html #[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)] pub enum Type { Adc, // Add with carry And, // Bitwise and Asl, // Arithmetic shift left Bcc, // Branch if carry clea...
true
01f3a8ec5c76216c36bfa6738a07de6535d04150
Rust
rgaertner/rust-examples
/src/bin/4-1-mutability.rs
UTF-8
418
3.25
3
[]
no_license
fn main() { // The compiler warns about unused variable bindings; these warnings can // be silenced by prefixing the variable name with an underscore let _immutable_binding = 1; let mut mutable_binding = 1; println!("Before mutation: {}", mutable_binding); // Ok mutable_binding += 1; ...
true
be550975d4d3eebbeb42ebae90e9f8571d4dd5ef
Rust
isgasho/dbcrossbar
/dbcrossbarlib/src/drivers/bigquery_shared/table_name.rs
UTF-8
4,039
3.375
3
[ "MIT", "Apache-2.0" ]
permissive
//! BigQuery table names. use lazy_static::lazy_static; use regex::Regex; use std::{fmt, str::FromStr}; use crate::common::*; use crate::drivers::bigquery::BIGQUERY_SCHEME; /// A BigQuery table name of the form `"project:dataset.table"`. #[derive(Clone, Debug, Eq, PartialEq)] pub(crate) struct TableName { /// Th...
true
cc79172e78c934e5ce8474bc030b8f2a9a2c4dec
Rust
getsentry/symbolic
/symbolic-testutils/src/lib.rs
UTF-8
768
3.578125
4
[ "MIT", "Apache-2.0" ]
permissive
//! Test helpers for `symbolic`. #![warn(missing_docs)] use std::path::{Path, PathBuf}; /// Returns the full path to the specified fixture. /// /// Fixtures are stored in the `testutils/fixtures` directory and paths should be given relative to /// that location. /// /// # Example /// /// ``` /// use symbolic_testutil...
true
99f1dac9a356b4e692a8939f6b48c2cf508a5527
Rust
ubaniabalogun/grapl
/src/rust/grapl-web-ui/src/authn/password.rs
UTF-8
878
2.609375
3
[ "Apache-2.0" ]
permissive
use argon2::{ Argon2, PasswordHash, PasswordVerifier, Version, }; pub struct Password(String); impl Password { #[tracing::instrument(skip(self))] pub fn verify_hash(&self, hash_to_verify: &str) -> Result<(), argon2::password_hash::Error> { // IMPORTANT: Keep in sync w/ https://github.c...
true
ca492def12e004febea03a08df8015071037e769
Rust
agabani/tor-operator
/src/cli.rs
UTF-8
4,247
2.796875
3
[ "MIT" ]
permissive
use std::path::PathBuf; use clap::{Args, Parser, Subcommand, ValueEnum}; /* * ============================================================================ * Cli * ============================================================================ */ #[allow(clippy::module_name_repetitions)] #[derive(Parser, Debug)] #[co...
true
2abc31c62dae86b6a0180b45b15e38ad590529c2
Rust
bdnelson/rust_parse_json
/src/bin/02_to_file.rs
UTF-8
603
3.359375
3
[]
no_license
use serde::{Serialize, Deserialize}; use serde_json; use std::io::{self}; #[derive(Serialize, Deserialize, Debug)] struct Person { name: String, age: i32, is_alive: bool } fn main() { let kristin = Person { name: String::from("Kristin"), age: 43, is_alive: true }; // I...
true
88e69891d6214a98ca71aa7c1b33e5446c715c75
Rust
QualityHammer/yaci
/src/bitwise.rs
UTF-8
341
2.8125
3
[]
no_license
pub fn get_address(opcode: u16) -> u16 { opcode & 0xFFF } pub fn get_nibble(opcode: u16) -> u16 { opcode & 0xF } pub fn get_x(opcode: u16) -> usize { ((opcode & 0xF00) >> 8) as usize } pub fn get_y(opcode: u16) -> usize { ((opcode & 0xF0) >> 4) as usize } pub fn get_byte(opcode: u16) -> u8 { (op...
true
2d9b5f1b0ec14d480b77f3a6ce2ee3126fee477b
Rust
trashbyte/voxelgame
/src/input.rs
UTF-8
1,436
3.4375
3
[ "MIT" ]
permissive
//! Input management. use std::collections::HashSet; /// Holds the current game input state. #[derive(Clone, Default)] pub struct InputState { keys_held: HashSet<::winit::VirtualKeyCode>, pub mouse_delta: (f64, f64), pub right_mouse_pressed: bool } impl InputState { pub fn new() -> InputState { ...
true
ab278e10f72de9cee3341d7154393e4b8712ad2e
Rust
chris-oo/crafting-interpreters-rust
/src/compiler.rs
UTF-8
18,248
2.71875
3
[]
no_license
use crate::bytecode::Opcodes; use crate::chunk::Chunk; use crate::debug::DEBUG_PRINT_CODE; use crate::lox_string_table::LoxStringTable; use crate::scanner; use crate::scanner::Scanner; use crate::scanner::Token; use crate::scanner::TokenType; use crate::value::Value; use crate::vm::InterpretError; use std::str::FromSt...
true
e8e44f6c7b693cdd687afd9a93c33bc7e70ee335
Rust
andrewcsmith/soundsym
/examples/reconstruction.rs
UTF-8
2,847
2.65625
3
[]
no_license
/// This is an "offline" version of reconstruction, meant to demonstrate what /// could conceivably be the final result. extern crate soundsym; extern crate getopts; use std::error::Error; use std::sync::Arc; use std::path::Path; use std::borrow::Cow; use std::env; use getopts::Options; use soundsym::*; fn main() ...
true
fda331214b667db4276977e00878f4155b5b0ee1
Rust
tmikus/rlox
/src/scanner.rs
UTF-8
4,621
3.234375
3
[]
no_license
use std::any::Any; use std::ptr::null; use token::Token; use token_type::TokenType; use token_type::TokenType::*; use error::error; use runtime_status::RuntimeStatus; pub struct Scanner { source: String, tokens: Vec<Token>, start: i32, current: i32, line: i32, } impl Scanner { pub fn new(source: String) -...
true
6ee52211c5d948726d786dc404ae55708a33d5b3
Rust
gsquire/sortpar
/src/main.rs
UTF-8
5,366
2.90625
3
[ "MIT" ]
permissive
#![warn(rust_2018_idioms)] use std::cmp::Ordering; use std::fs::{File, OpenOptions}; use std::io::{self, prelude::*, BufRead, BufReader, BufWriter}; use clap::ArgMatches; use itertools::Itertools; use rayon::slice::ParallelSliceMut; use version_compare::Version; use self::filter::{filter_function, Filter}; #[cfg(te...
true
5825b9654e358115949a98bebbbcba1bd7c0f769
Rust
smokytheangel0/hack_the_test0
/sorter_rs/src/main.rs
UTF-8
28,558
3.328125
3
[ "Apache-2.0" ]
permissive
use std::collections::HashMap; use std::fs; use std::env; extern crate dirs; #[allow(bad_style)] fn identify() -> HashMap<String, Vec<String>> { let mut map: HashMap<String, Vec<String>> = HashMap::new(); //find files matching certain endings and add them //to the correct key of the HashMap (i.e. <"videos"...
true
d66934b45b09708d3f1b9939106f797c0358987a
Rust
sourceplayer/qupla_rust
/src/dispatcher/entity.rs
UTF-8
2,624
3.25
3
[]
no_license
use crate::helper::tritvector::{ TritVector }; use crate::dispatcher::effect::Effect; use crate::dispatcher::environment::Environment; use crate::dispatcher::event::Event; use crate::dispatcher::supervisor::Supervisor; #[derive(Clone)] pub struct Entity<'a> { supervisor: &'a mut Supervisor<'a>, effects: Vec<Ef...
true
fd50a4ddf60082a322c54d7d6163df228236ea42
Rust
PacktPublishing/Rust-Standard-Library-Cookbook
/Chapter03/src/bin/bytes.rs
UTF-8
2,159
3.59375
4
[ "MIT" ]
permissive
extern crate byteorder; use std::io::{Cursor, Seek, SeekFrom}; use byteorder::{BigEndian, LittleEndian, ReadBytesExt, WriteBytesExt}; fn main() { let binary_nums = vec![2, 3, 12, 8, 5, 0]; // Wrap a binary collection in a cursor // to provide seek functionality let mut buff = Cursor::new(binary_nums); ...
true
66a5997a21df06d9148d7cb4b106b01e54215a9d
Rust
AustinJ235/vulkano
/vulkano/src/instance/mod.rs
UTF-8
34,714
2.828125
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
// Copyright (c) 2016 The vulkano developers // Licensed under the Apache License, Version 2.0 // <LICENSE-APACHE or // https://www.apache.org/licenses/LICENSE-2.0> or the MIT // license <LICENSE-MIT or https://opensource.org/licenses/MIT>, // at your option. All files in the project carrying such // notice may not be ...
true
eb76d644187a97a4b85af4fcd7a785060c5e85f5
Rust
dave-tucker/mdns
/src/discover.rs
UTF-8
4,027
3.078125
3
[ "MIT" ]
permissive
//! Utilities for discovering devices on the LAN. //! //! Examples //! //! ```rust,no_run //! use futures_util::{pin_mut, stream::StreamExt}; //! use mdns::{Error, Record, RecordKind}; //! use std::time::Duration; //! //! const SERVICE_NAME: &'static str = "_googlecast._tcp.local"; //! //! #[async_std::main] //! async ...
true
8f58bfe6d61747feffb97624ff7e9b7a0d73f656
Rust
marco-c/gecko-dev-wordified
/third_party/rust/num_cpus/src/linux.rs
UTF-8
16,059
2.6875
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT", "Apache-2.0" ]
permissive
use std : : collections : : HashMap ; use std : : fs : : File ; use std : : io : : { BufRead BufReader Read } ; use std : : mem ; use std : : path : : { Path PathBuf } ; use std : : sync : : atomic : : { AtomicUsize Ordering } ; use std : : sync : : Once ; use libc ; macro_rules ! debug { ( ( args : expr ) * ) = > ( { ...
true
afaf89eab3404e7d20bbab37cb11f3731125dfba
Rust
shadowsocks/shadowsocks-rust
/src/daemonize/unix.rs
UTF-8
792
2.5625
3
[ "MIT" ]
permissive
use std::{env::current_dir, path::Path}; use daemonize::Daemonize; use log::error; /// Daemonize a server process in a *nix standard way /// /// This function will redirect `stdout`, `stderr` to `/dev/null`, /// and follow the exact behavior in shadowsocks-libev pub fn daemonize<F: AsRef<Path>>(pid_path: Option<F>) {...
true
6d063ef0ea6f01d005c52dd290c47cec5f65aeb3
Rust
fanhaipeng0403/1sol-protocol
/src/program-rust/src/swappers/spl_token_swap.rs
UTF-8
5,699
2.578125
3
[]
no_license
use solana_program::{ account_info::{next_account_info, AccountInfo}, instruction::{AccountMeta, Instruction}, program::invoke, program_error::ProgramError, pubkey::Pubkey, }; use std::mem::size_of; /// Swap instruction data #[repr(C)] #[derive(Clone, Debug, PartialEq)] pub struct Swap { /// SO...
true
60ec6bdbaf328b8842131ae069152ed3e91b42eb
Rust
lucas-miranda/tree_decorator
/src/decorator/style_item_value.rs
UTF-8
499
2.765625
3
[ "MIT" ]
permissive
use super::Entry; /// Style item value behavior to implement at each possible type available at [`Style`]. /// /// [`Style`]: crate::decorator::Style pub trait StyleItemValue { fn default_enable_value() -> Self; } /// Default enable value is `true`. impl StyleItemValue for bool { fn default_enable_value() -> ...
true
5322631a77234131a51bd5d53986db8eaa559e96
Rust
samarties/leetcode-rust
/src/n0016_3_sum_closest.rs
UTF-8
3,138
3.703125
4
[]
no_license
pub struct Solution {} impl Solution { pub fn three_sum_closest(nums: Vec<i32>, target: i32) -> i32 { let sorted_nums = Solution::sort_nums(nums.clone()); let mut closest_difference: i32 = 0; let mut closest_sum: i32 = 0; let mut index_a: usize = 0; while index_a < (nums.l...
true
3aa2831c54926d64bad9ac52966aa82018ae1335
Rust
brunoflores/gcd
/src/lib.rs
UTF-8
459
3.546875
4
[ "Apache-2.0" ]
permissive
pub fn gcd(mut n: u64, mut m: u64) -> u64 { assert!(n != 0 && m != 0); while m != 0 { if m < n { let t = m; m = n; n = t; } println!("n: {}, m: {}", n, m); let prov = m % n; println!("{} % {} = {}", m, n, prov); m = prov; } ...
true
62cd2dd968a1705d507d68c1334029f7d5fe6a41
Rust
nautical/compyler
/src/error.rs
UTF-8
241
2.625
3
[]
no_license
use token::Token; #[derive(Debug, PartialEq)] pub enum Error { UnexpectedStartOfToken(char), UnexpectedCharacter(Option<char>), UnpairedBackslash(Option<char>), UnmatchedIndentationLevel(u64), UnexpectedToken(Token), }
true
7f3618ae494db4329009a9e6c185f0b45866755f
Rust
alpha-tango-kilo/aoc-2020
/day_8/src/main.rs
UTF-8
1,555
3.046875
3
[ "MIT" ]
permissive
use anyhow::{Result, Context}; use std::fs; use day_8::{Computer, read_program, generate_permutations}; fn main() -> Result<()> { let input = fs::read_to_string("./day_8/input")?; let program = read_program(input)?; let mut computer_one = Computer::new(program.clone()); let part_one = computer_one.part...
true
edbaecae30634d99b8e3cf83356976d09fd535d7
Rust
Weltraumschaf/minivm
/src/frontend/mod.rs
UTF-8
1,299
3.21875
3
[]
no_license
///! frontend module of Mini VM. use std::fmt; pub mod character_stream; pub mod character_helper; pub mod lexer; pub mod parser; pub mod token; /// Describes a character position in the source string. #[derive(Debug, PartialEq)] pub struct Position { line: u64, column: u64, } impl Position { /// Return...
true
52fa257ff54b244af270f556d59449aa47157232
Rust
PatiPavanSai/rust-cardano
/storage/src/block/range.rs
UTF-8
1,112
2.515625
3
[ "MIT", "Apache-2.0" ]
permissive
use refpack; use super::super::{Storage}; use types::{BlockHash}; use super::error::{Error, Result}; use super::iter::{ReverseIter}; use storage_units::reffile; use std::collections::VecDeque; pub struct Range(VecDeque<BlockHash>); impl Range { pub fn new(storage: &Storage, from: BlockHash, to: BlockHash) -> Resu...
true
ea8b1a99f79ab4a63ceb19bbc3071a9e84b4e933
Rust
hasp-rs/hasp
/hasp/src/output/mod.rs
UTF-8
2,244
2.59375
3
[ "MIT", "Apache-2.0" ]
permissive
// Copyright (c) The hasp Contributors // SPDX-License-Identifier: MIT OR Apache-2.0 mod formatters; mod subscriber; pub(crate) use formatters::*; use structopt::StructOpt; #[derive(Copy, Clone, Debug, StructOpt)] #[must_use] pub(crate) struct OutputOpts { /// Suppress output #[structopt( name = "ou...
true
c8920379b984b113277e2eab419db66daa6ba60e
Rust
oxalica/nix-cache-mirror
/src/database/model.rs
UTF-8
11,910
2.6875
3
[]
no_license
use chrono::{DateTime, Utc}; use failure::{format_err, Error}; use serde::{Deserialize, Serialize}; use std::{borrow::Borrow, convert::TryFrom, fmt}; #[derive(Debug, Default)] pub struct Root { pub channel_url: Option<String>, pub cache_url: Option<String>, pub git_revision: Option<String>, pub fetch_t...
true
99b99d8a66b26c3595ecfec32d0778923c4072c9
Rust
allenap/allenap-libtftp
/src/packet.rs
UTF-8
11,391
3.109375
3
[]
no_license
extern crate byteorder; use std::error; use std::fmt; use std::io; use std::result; use super::options::Options; use super::packetreader; use super::packetwriter; /// An error reading, parsing, or writing a packet. #[derive(Debug,PartialEq)] pub enum Error { /// The operation is invalid / not recognised. In...
true
8eca17e764bcfbc90b075df0c483cf1223472990
Rust
rustic-games/conventional-commit
/src/error.rs
UTF-8
2,863
3.53125
4
[]
no_license
//! All errors related to Conventional Commits. use std::fmt; /// The error returned when parsing a commit fails. #[derive(Clone, Debug, Eq, PartialEq)] pub struct Error { kind: ErrorKind, commit: Option<String>, } impl Error { /// Create a new error from a `ErrorKind`. pub(crate) fn new(kind: Error...
true
656b5f0743148c64d3b9b2a26e8476bec354b45d
Rust
leod/diffdag
/src/lib.rs
UTF-8
2,412
2.890625
3
[ "MIT" ]
permissive
extern crate ndarray; use std::rc::Rc; use std::ops::{Add, Sub, Mul, Neg}; use ndarray::{LinalgScalar, Shape}; use ndarray::prelude::*; #[derive(Clone, Debug)] pub enum ParameterInit<A: LinalgScalar> { Value(ArrayD<A>), } #[derive(PartialEq, Eq, Clone, Debug)] pub struct ParameterId(usize); pub struct Paramete...
true
8bb88a8a4e356cc174f90cd0a91193e86f4f9fec
Rust
DarthGandalf/advent-of-code
/2018/day6/src/main.rs
UTF-8
3,100
2.90625
3
[]
no_license
use std::time::Instant; use std::collections::VecDeque; use std::collections::HashMap; fn _solve1(input: &str) -> i32 { let points : Vec<_> = input.lines().map(|line| { let mut t = line.split(','); let x : usize = t.next().unwrap().trim().parse().unwrap(); let y : usize = t.next().unwrap().trim().parse().unwrap...
true
d8de3aa185b9878dfc94bbc5f3060c11f0a384a2
Rust
extrawurst/rapier
/src/geometry/contact_pair.rs
UTF-8
6,859
2.75
3
[ "Apache-2.0" ]
permissive
use crate::dynamics::{BodyPair, RigidBodyHandle}; use crate::geometry::{ColliderPair, ContactManifold}; use crate::math::{Point, Real, Vector}; use parry::query::ContactManifoldsWorkspace; bitflags::bitflags! { #[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))] /// Flags affecting the beh...
true
0c7277848101ef0e34699712f6cd431897a9d290
Rust
blaenk/glob-prime
/src/pattern.rs
UTF-8
15,190
3.375
3
[]
no_license
use regex::Regex; use std::fmt; use std::path; use self::Token::{ Char, AnyChar, AnySequence, AnyRecursiveSequence, AnyWithin, AnyExcept }; use self::CharSpecifier::{SingleChar, CharRange}; #[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Show)] enum Token { Char(char), AnyChar, AnySequence, ...
true
8d14dabb7a498d3a9e9fe497ad0d40372ce3ba21
Rust
monoid/DuHasT
/src/dht.rs
UTF-8
18,822
2.625
3
[]
no_license
extern crate rand_chacha; extern crate rand_core; extern crate serde_bencoded; use std::borrow::Cow; use std::fmt; use std::fs::File; use std::io::{Read, Write}; use std::net::IpAddr; use std::net::Ipv4Addr; use std::net::SocketAddrV4; use fmt::Debug; use rand::rngs::OsRng; use rand::{CryptoRng, Rng, RngCore, Seedabl...
true
ecdf9972b0409e0579134a3a5d32916cc3e67833
Rust
BurNiinTRee/NeuralNet
/src/matrix.rs
UTF-8
1,244
3.6875
4
[]
no_license
/// A Matrix to store the weights infront of one layer /// It also contains a `bias` as an additional value pub struct WeightMatrix<W: Clone> { elements: Vec<W>, pub width: usize, pub height: usize, } impl<W: Clone> WeightMatrix<W> { /// Creates a new `WeightMatrix` from the given elements, the bias, a...
true
872e029c702690beebfd6b9d74d17bcf721cf716
Rust
blakesmith/arrow2
/tests/it/array/growable/utils.rs
UTF-8
2,200
2.78125
3
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
use crate::{ array::{Array, Offset}, bitmap::{Bitmap, MutableBitmap}, buffer::MutableBuffer, }; pub(super) fn extend_offsets<T: Offset>( buffer: &mut MutableBuffer<T>, last_offset: &mut T, offsets: &[T], ) { buffer.reserve(offsets.len() - 1); offsets.windows(2).for_each(|offsets| { ...
true
a3075000e02ac3724d04ae41f29e320f40395653
Rust
rust-git/rsgit
/core/src/object/check_tree.rs
UTF-8
23,332
2.71875
3
[ "Apache-2.0" ]
permissive
use std::{cmp::Ordering, collections::HashSet, io::BufRead}; use crate::{ object::{parse_utils, ContentSource, ContentSourceResult}, path::{CheckPlatforms, FileMode, PathMode, PathSegment}, }; use unicode_normalization::UnicodeNormalization; pub(crate) fn tree_is_valid(s: &dyn ContentSource) -> ContentSource...
true
b42132a7c27f34bd402e6f025df91c7b70b9f82c
Rust
isgasho/treexml-rs
/tests/write.rs
UTF-8
5,352
3
3
[ "MIT" ]
permissive
extern crate treexml; mod write { mod document { use treexml::{Document, Element}; #[test] fn simple_document() { let mut root = Element::new("root"); let child = Element::new("child"); root.children.push(child); let doc = Document { ...
true
bcb10f40ed06d97b68d85664681d8997e45b4869
Rust
bokotomo/rust-api-sample
/src/domain/job.rs
UTF-8
2,416
3.109375
3
[]
no_license
// 求人の情報 use super::super::domain::company::DomainCompany; pub struct DomainJob { id: i32, company: DomainCompany, // 仕事名 title: String, // サブタイトル title_sub: String, // タグ tag: String, // 仕事詳細 description: String, // 期限 recruiment_period: String, // 仕事場所 location...
true
7bb847f94530cc7fc483ec5d3bb60de8a3711c22
Rust
bgamari/succinct.rs
/src/bits.rs
UTF-8
1,956
4.03125
4
[]
no_license
//! Various traits for working with bits and objects composed of them use std::ops::{Shr, BitAnd}; use std::iter::Iterator; use std::num::Int; use std::mem::size_of; /// An iterator over the bits of a primitive type /// The least significant bit is produced first. pub struct BitIterator<T> { bit: uint, x: T, ...
true
b22cc3e09c7c98cdd93de8edd0c7fb226a15ef47
Rust
subhojit777/minigrep
/src/minigrep/error.rs
UTF-8
755
3.3125
3
[ "Apache-2.0", "MIT" ]
permissive
use std::error::Error; use std::fmt; /// Minigrep error. #[derive(Debug)] pub struct MinigrepError { message: String, } impl MinigrepError { pub fn new(message: &str) -> Self { MinigrepError { message: message.to_string(), } } } impl fmt::Display for MinigrepError { fn fmt...
true
d2a3ec7972364fa22714e1ab091c878d7536cd58
Rust
rome/tools
/crates/rome_js_formatter/src/ts/assignments/as_assignment.rs
UTF-8
3,715
2.875
3
[ "MIT" ]
permissive
use crate::prelude::*; use crate::parentheses::NeedsParentheses; use rome_formatter::{format_args, write}; use rome_js_syntax::{AnyJsAssignment, AnyTsType, JsSyntaxKind, JsSyntaxNode, JsSyntaxToken}; use rome_js_syntax::{TsAsAssignment, TsSatisfiesAssignment}; use rome_rowan::{declare_node_union, SyntaxResult}; #[der...
true
6e1824eb09293fedf595a20b1934f9bea9724cc8
Rust
stephaneyfx/cargo-geiger
/cargo-geiger/src/traversal.rs
UTF-8
6,606
2.78125
3
[ "Apache-2.0", "MIT" ]
permissive
use crate::format::print::{Prefix, PrintConfig}; use crate::format::tree::{get_tree_symbols, TextTreeLine}; use crate::graph::{Graph, Node}; use cargo::core::dependency::DepKind; use cargo::core::PackageId; use petgraph::visit::EdgeRef; use petgraph::EdgeDirection; use std::collections::HashSet; /// To print the retu...
true
c80e65465396946a069d9fa22a4e911b7dc17350
Rust
Rand01ph/learning-rust
/concurrency-fun/src/main.rs
UTF-8
259
2.890625
3
[ "MIT" ]
permissive
use std::sync::{Arc, Mutex}; use std::thread; fn main() { let v = Arc::new(Mutex::new(vec![1,2,3])); for i in 0..3 { let cloned_v = v.clone(); thread::spawn(move || { cloned_v.lock().unwrap().push(i); }); } }
true
24010ba12f8ddc190b815f3a1a71624dd1c0b4c1
Rust
yuewuo/fusion-blossom
/src/dual_module.rs
UTF-8
69,826
2.875
3
[ "MIT" ]
permissive
//! Dual Module //! //! Generics for dual modules, defining the necessary interfaces for a dual module //! #![cfg_attr(feature = "unsafe_pointer", allow(dropping_references))] use super::pointers::*; use super::util::*; use super::visualize::*; use crate::derivative::Derivative; use core::cmp::Ordering; use std::colle...
true