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
3f00963123b87921d3eefbbe27b9990e233ff837
Rust
edgedb/edgedb-cli
/edgedb-cli-derive/src/types.rs
UTF-8
2,747
2.578125
3
[ "Apache-2.0", "MIT" ]
permissive
use syn::spanned::Spanned; use crate::attrib; pub struct Struct { pub attrs: attrib::ContainerAttrs, pub vis: syn::Visibility, pub ident: syn::Ident, pub generics: syn::Generics, pub fields: Vec<Field>, } pub struct Enum { pub attrs: attrib::ContainerAttrs, pub vis: syn::Visibility, ...
true
77aac0408245832aaa7479ab8861fe4e9772d543
Rust
bottlerocket-os/bottlerocket
/sources/api/netdog/src/cli/generate_hostname.rs
UTF-8
3,790
2.734375
3
[ "Apache-2.0", "MIT" ]
permissive
use super::{error, print_json, Result}; use crate::CURRENT_IP; use argh::FromArgs; use dns_lookup::lookup_addr; use snafu::ResultExt; use tokio::time::Duration; use tokio_retry::{ strategy::{jitter, FibonacciBackoff}, Retry, }; use std::fs; use std::net::IpAddr; use std::str::FromStr; // Maximum number of ret...
true
c61e72c3d4df4d7827ce67da4c0fd4f8997bf01e
Rust
UltiNaruto/randomprime
/generated/dol_symbol_table/dol_symbol_table_macro/build.rs
UTF-8
2,060
2.515625
3
[ "MIT" ]
permissive
use std::env; use std::fs::File; use std::io::{BufRead, BufReader, BufWriter, Write}; use std::path::Path; fn main() { let output_path = Path::new(&env::var("OUT_DIR").unwrap()).join("codegen.rs"); let mut output_file = BufWriter::new(File::create(&output_path).unwrap()); const GAME_VERSIONS: &[(&str, &st...
true
aa4c12945a2df3073dafcfbf0bc34dfa2d6bae4f
Rust
isgasho/cargo-review-deps
/src/main.rs
UTF-8
5,904
2.6875
3
[ "MIT", "Apache-2.0" ]
permissive
extern crate cargo_review_deps; extern crate clap; use std::{ffi::OsStr, path::PathBuf}; use cargo_review_deps::{Current, Diff, PackageId, Result, UpdateDiff}; use clap::{App, AppSettings, Arg, ArgMatches, SubCommand}; fn main() { let exit_code = main_inner(); std::process::exit(exit_code); } fn main_inner(...
true
061c3d455d5ee44ac97f871094703dbe34cd32bc
Rust
joeftiger/rust-v
/geometry/src/aabb.rs
UTF-8
5,570
3.28125
3
[ "MIT" ]
permissive
use crate::ray::Ray; #[cfg(test)] use crate::UNIT_VECTORS; use crate::*; use crate::{Boundable, Container, Geometry, Intersectable, Intersection}; use serde::{Deserialize, Serialize}; use utility::floats::FloatExt; /// A cube represents an axis-aligned bounding box in 3 dimension. It is very efficient using only /// 2...
true
83c29fc97026800692597090d5515eb43bedec48
Rust
rome/tools
/xtask/codegen/src/generate_new_lintrule.rs
UTF-8
4,719
2.734375
3
[ "MIT" ]
permissive
use std::{path::PathBuf, str::FromStr}; use case::CaseExt; pub fn generate_new_lintrule(path: &str, rule_name: &str) { let rule_folder = PathBuf::from_str(path).unwrap(); match rule_folder.file_stem().and_then(|x| x.to_str()) { Some("nursery") => {} _ => { panic!("all new rules mus...
true
53c1982f51551f38ef31502017c7505b9cacc36c
Rust
maxblee/clipivot
/tests/test_cli.rs
UTF-8
6,160
2.78125
3
[ "MIT", "Apache-2.0" ]
permissive
use assert_cmd::Command; use std::process::Output; /// This module holds most of the integration tests (basically everything but numerical accuracy tests) use std::str; #[macro_use] mod common; fn setup_cmd(query: &[&str]) -> Output { let program_name = program_path!(); Command::new(program_name) .arg...
true
93fa4d2f568a7c3b7b9f73afc38f4d99dbd42510
Rust
Trolldemorted/cached_file_view
/src/lib.rs
UTF-8
7,148
2.75
3
[]
no_license
use std::borrow::Borrow; use std::sync::Arc; use std::sync::Mutex; use std::fs::File; use std::io::Read; use std::io::Seek; use std::io::SeekFrom; use std::ops::Range; use std::io; use std::collections::HashMap; use std::fmt; const DEBUG: bool = false; const CHUNK_SIZE: usize = 0x8000; #[derive(Debug, ...
true
c99c631e01e07b7084739a1b9a82b86a8878e377
Rust
ZeusWPI/Planetwars
/backend/src/routes/info.rs
UTF-8
756
2.96875
3
[]
no_license
use rocket::response::Redirect; use rocket::Route; use rocket_contrib::templates::Template; use crate::util::*; const MAX: usize = 6; /// Redirects to the first info page #[get("/info")] fn info_base() -> Redirect { Redirect::to("/info/1") } /// Renders the <page> info page #[get("/info/<page>")] async fn info...
true
365dfbbd21437acba2d6178b8b4a797e8ed07b6d
Rust
roy-ganz/toql
/crates/core/src/sql_builder.rs
UTF-8
75,961
2.609375
3
[ "MIT", "Apache-2.0" ]
permissive
//! The SQL builder can build different select statements. pub mod build_result; pub mod select_stream; pub mod sql_builder_error; pub(crate) mod build_context; pub(crate) mod path_tree; use crate::{ error::ToqlError, parameter_map::ParameterMap, query::{ concatenation::Concatenation, field_order:...
true
12b45fbf6a60086878166dff9c812faac413e0b2
Rust
Garvys/rustfst
/rustfst/src/fst_impls/const_fst/fst.rs
UTF-8
3,028
2.75
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use std::sync::Arc; use anyhow::{format_err, Result}; use crate::fst_impls::ConstFst; use crate::fst_properties::FstProperties; use crate::fst_traits::{CoreFst, Fst}; use crate::semirings::Semiring; use crate::{StateId, SymbolTable, TrsConst}; impl<W: Semiring> Fst<W> for ConstFst<W> { fn input_symbols(&self) ->...
true
6d0e1afef4db8fd44155d8fd78202f4b9b315fbd
Rust
noeddl/ukebox
/src/chord_chart.rs
UTF-8
5,894
2.984375
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use std::cmp::max; use std::fmt; use crate::{FretID, Semitones, UkeString, Voicing, MIN_CHART_WIDTH}; pub struct ChordChart { voicing: Voicing, /// Number of frets to use to display the chord voicing width: Semitones, } impl ChordChart { pub fn new(voicing: Voicing, width: Semitones) -> Self { ...
true
c61fbbf5d225af46ad5ea3ffa8d13efcb6d73c1c
Rust
facebookexperimental/MIRAI
/checker/tests/run-pass/use_copy.rs
UTF-8
528
2.53125
3
[ "MIT" ]
permissive
// Copyright (c) Facebook, Inc. and its affiliates. // // This source code is licensed under the MIT license found in the // LICENSE file in the root directory of this source tree. // // A test that exercises visit_used_copy with a structured value. use mirai_annotations::*; #[derive(Clone, Copy)] struct Point { ...
true
e394bfbe2d500eaa9db1c6c49afa1d77645d350f
Rust
diatoner/gstm
/gstm_core/src/lib.rs
UTF-8
7,335
2.71875
3
[ "MIT" ]
permissive
use std::collections::HashMap; use std::io::prelude::*; use chrono::{DateTime, FixedOffset}; use reqwest::{header, Client}; use serde::{Deserialize, Serialize}; use thiserror::Error; #[cfg(test)] fn get_api_endpoint() -> String { std::env::var("_gstm_mock_api_endpoint").unwrap() } #[cfg(test)] fn set_api_endpoin...
true
d2be9bbb4a8777c5f647b39bdb95343ff1348ee8
Rust
xfbs/euler
/src/010-summation-of-primes/rust/src/lib.rs
UTF-8
318
3.03125
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
extern crate euler; use euler::Sieve; pub fn solve(n: u64) -> u64 { Sieve::new(n as usize).into_iter().sum() } #[test] fn test_solve() { assert!(solve(10) == 2 + 3 + 5 + 7); assert!(solve(20) == 2 + 3 + 5 + 7 + 11 + 13 + 17 + 19); assert!(solve(30) == 2 + 3 + 5 + 7 + 11 + 13 + 17 + 19 + 23 + 29); }
true
e149c1bd1e64801cc4877782459c39c71b264399
Rust
AnderEnder/tarpaulin
/tests/data/multi_function_ta/src/lib.rs
UTF-8
302
3.203125
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
fn simple_branch(x: u32) { if x > 10 { println!("Big"); } else { println!("Small"); } } #[cfg(test)] mod tests { use simple_branch; #[test] fn branch1() { simple_branch(0); } #[test] fn branch2() { simple_branch(11); } }
true
fa341de9b11744c15ee30886bfae6280b09ee776
Rust
albinocordeiro/kiwirail
/src/bin/kiwicli.rs
UTF-8
2,706
2.84375
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT", "Apache-2.0" ]
permissive
use clap::Clap; use color_eyre::eyre::Result; use petgraph::graphmap::DiGraphMap; use kiwirail::input_parsing::*; use kiwirail::shortest_route::*; use kiwirail::route_distance::*; use kiwirail::route_count::*; fn main() -> Result<()> { color_eyre::install()?; println!(r#" _ |...
true
5bce4bcb9fe6f5094217985aea000441ad09865d
Rust
tbremer/adventofcode
/2015/utils/src/lib.rs
UTF-8
1,243
3.265625
3
[]
no_license
use core::panic; use std::env; use std::fmt::Display; use std::fs::File; use std::io::prelude::Read; use std::str::FromStr; pub fn args() -> Vec<String> { let mut arguments: Vec<String> = env::args_os() .map(|i| match i.to_str() { Some(v) => v.to_owned(), None => panic!("No string f...
true
306ff8ccc2bbd01c3959e8b8540318a53b161035
Rust
Apanatshka/dnfa
/src/automaton.rs
UTF-8
2,165
2.984375
3
[ "MIT" ]
permissive
use std::fmt::Debug; pub trait Automaton<Input: Ord> { type State: Debug; fn start_state(&self) -> Self::State; fn stuck_state(&self) -> Self::State; fn next_state(&self, state: &Self::State, input: &Input) -> Self::State; fn has_match(&self, si: &Self::State, patt_no_offset: usize) -> bool; ...
true
ae7076623bccd5861c3be7a0880ff98bd009e992
Rust
philipc/tinyrenderer-rs
/src/tga.rs
UTF-8
5,565
2.765625
3
[]
no_license
use image; use std::{ fs, io, mem, path, slice }; use std::io::Read; use std::io::Write; #[derive(Default)] struct Le16 { buf: [u8; 2] } impl From<Le16> for u16 { fn from(le16: Le16) -> Self { u16::from_le(unsafe { mem::transmute(le16.buf) }) } } impl From<u16> for Le16 { fn from(n: u16) -> Self { Le16 { ...
true
0bae731842c54db585bda0491cc2729428e9fbaf
Rust
cberner/fleetfs
/src/base/raft_utils.rs
UTF-8
670
2.78125
3
[ "Apache-2.0" ]
permissive
pub fn node_contains_raft_group( node_index: usize, total_nodes: usize, raft_group_id: u16, replicas_per_raft_group: usize, ) -> bool { assert_eq!( total_nodes % replicas_per_raft_group, 0, "{} % {} != 0", total_nodes, replicas_per_raft_group ); // Di...
true
911138e9702a444c80a7a875936907d60ce8186e
Rust
satvik-1203/rust-sandbox
/src/test.rs
UTF-8
252
2.96875
3
[]
no_license
#[derive(Debug)] struct Person { name: String, } pub fn run() { let satvik: Person = Person { name: String::from("satvik"), }; let copySatvik = &satvik; // copySatvik.name = String::from("newName"); println!("{:#?}", copySatvik); }
true
ac9f3a963d6de14cdabadade68a252e55ecbe341
Rust
LDiazN/TypeManager
/TypeManager/src/driver/mod.rs
UTF-8
7,401
3.609375
4
[]
no_license
/* Main driver code */ // Rust imports use std::io; use std::io::Write; // Internal imports use crate::type_system::*; /// Our program object pub struct Program { running: bool, manager: TypeManager } /// possible errors pub enum ProgramError { NotEnoughArgs, TooManyArgs, InvalidAction(Stri...
true
5de30efc2a37cb24f541fdcee735c714c2c4816b
Rust
lnguyenfx/ml-from-scratch
/src/tests/test_neural_network.rs
UTF-8
4,526
3.078125
3
[ "MIT" ]
permissive
use super::super::matrix::Matrix; use super::super::neural_network::NeuralNetwork; #[test] fn test_nn_set_weights() { let num_inputs = 2; let num_layers = 2; let mut nn = NeuralNetwork::new(num_inputs, num_layers); let weights_layer1 = Matrix::from_vec(&vec![1.0, 0.75, 0.5, 0.25], num_inputs, num_inpu...
true
8cb4b29ae3ee4ef262a29712cf025e4067d6b15f
Rust
bbucko/rusty-pew-pew
/src/game/mod.rs
UTF-8
2,786
3.03125
3
[]
no_license
use cgmath::Vector2; use std::time::SystemTime; mod engine; mod game_object; mod misc; mod level; pub mod states; pub type Position = Vector2<i32>; pub type Velocity = Vector2<i32>; pub type Id = usize; pub struct Engine<R: Renderer, I: InputHandler> { pub is_running: bool, renderer: R, input_handler: I,...
true
0bde3a91dae783f2d69410b4a7486218ca783a6c
Rust
paritytech/ed25519-dalek
/src/ed25519.rs
UTF-8
17,322
2.53125
3
[ "BSD-3-Clause" ]
permissive
// -*- mode: rust; -*- // // This file is part of ed25519-dalek. // Copyright (c) 2017-2019 isis lovecruft // See LICENSE for licensing information. // // Authors: // - isis agora lovecruft <isis@patternsinthevoid.net> //! ed25519 keypairs and batch verification. use core::default::Default; use rand::CryptoRng; use ...
true
35e911e0740b4df42c6648b72a21c62d9ac64eb6
Rust
MamadouSDiallo/rust-book-learning
/chapter11/src/lib.rs
UTF-8
301
2.828125
3
[]
no_license
pub mod difference; #[cfg(test)] mod tests { #[test] fn it_works() { assert_eq!(2 + 2, 4); } } #[test] #[ignore] fn another() { panic!("Make this test fail") } #[test] fn another2() { assert_ne!(2 + 2, 3); } pub fn add_two_integers(x: i32, y: i32) -> i32 { x + y }
true
3c34971ce6f1155dc7d241e85116687bc87b0f36
Rust
isgasho/wosim
/crates/protocol/src/notification.rs
UTF-8
2,226
2.859375
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use network::{DeserializeError, RawMessage, SerializeMessage, TryDeserializeMessage}; use crate::{ DynamicSetup, DynamicUpdate, GlobalSetup, GlobalUpdate, RegionPos, StaticSetup, StaticUpdate, WorldEnter, }; #[derive(Debug)] pub enum Notification { GlobalSetup(GlobalSetup), StaticSetup((RegionPos, Sta...
true
eeb8e7745cd39dfac6ab96f276268d9aa31a7b02
Rust
tylerwhall/rust
/src/libcoretest/tuple.rs
UTF-8
1,842
3.078125
3
[ "Apache-2.0", "LicenseRef-scancode-other-permissive", "MIT", "Unlicense", "BSD-3-Clause", "bzip2-1.0.6", "NCSA", "ISC", "LicenseRef-scancode-public-domain", "BSD-2-Clause" ]
permissive
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
true
cdf2032f3036c9ff5f43cfa2fa29fec797abaf90
Rust
KamilFCB/Studies
/Rust/Lista5/src/zad1.rs
UTF-8
662
3.46875
3
[]
no_license
fn xo(string: &'static str) -> bool { let str: String = string.to_string(); str.chars().into_iter().filter(|ch| *ch == 'x' || *ch == 'X').count() == str.chars().into_iter().filter(|ch| *ch == 'o' || *ch == 'O').count() } #[test] fn returns_expected() { assert_eq!(xo("xo"), true); assert_eq!(xo("Xo"), ...
true
2cdacaba3fdb03bbb24969bb100f4b97df98f8d7
Rust
KrystianGrabowski/University
/Rust/l3/task1/src/main.rs
UTF-8
944
3.515625
4
[]
no_license
fn main() { println!("{}", row_sum_odd_numbers(1)); } fn row_sum_odd_numbers(n:i64) -> i64 { n * n * n } #[test] fn odd_triangle_test_1() { assert_eq!(row_sum_odd_numbers(1), 1); } #[test] fn odd_triangle_test_2() { assert_eq!(row_sum_odd_numbers(42), 74088); } #[test] fn odd_triangle_test_3() { a...
true
f172e0839ed3eb67730d9fe87b0bbabd7c587fe1
Rust
funkiben/Rust-HTTP
/src/server/slab.rs
UTF-8
3,524
3.9375
4
[]
no_license
use std::collections::VecDeque; /// A data structure with preallocated space for elements. /// The slab will find empty slots for new elements and return the index where it was inserted. pub struct Slab<T> { data: Vec<Option<T>>, open_slots: VecDeque<usize>, } impl<T> Slab<T> { /// Creates a new slab with...
true
f9d25649f18c2acad95f1b5fe0c6d75d7c61206b
Rust
celtra/k8s-aws-nlb-proxy-protocol-operator
/vendor/time/src/weekday.rs
UTF-8
7,371
3.53125
4
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use core::fmt::{self, Display}; /// Days of the week. /// /// As order is dependent on context (Sunday could be either /// two days after or five days before Friday), this type does not implement /// `PartialOrd` or `Ord`. #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[cfg_attr( fea...
true
82745d39dc8c694fec70020f55e2ce2f91652fcc
Rust
vinayak-mehta/tcr
/src/main.rs
UTF-8
3,075
3.046875
3
[]
no_license
use notify::{RecommendedWatcher, RecursiveMode, Watcher}; use std::io::{self, Write}; use std::path::Path; use std::process::Command; mod orchestrator; use orchestrator::Runner; // "ls -al" => Command::new("ls").arg("-al"); fn cmd_from_string(s: String) -> Result<std::process::Command, &'static str> { let mut it...
true
4511374e0ac678657df9bf2ae0d7527292638fa1
Rust
toyseed/WebServer_2
/src/route/router.rs
UTF-8
1,140
2.859375
3
[ "MIT" ]
permissive
use crate::http::{HttpRequest, HttpResponse, HttpResponseBuilder, HttpStatus}; use crate::route::route::Route; // find a route and execute route's handler. pub struct Router { routes: Vec<Box<dyn Route>>, } impl Router { pub fn new(routes: Vec<Box<dyn Route>>) -> Self { Router { routes } } //...
true
a700218968f8a3c1a5ee68cd07c7b08e4d04affd
Rust
iasoon/KeyboardOptimizer-LayoutGen-3000
/src/data/types.rs
UTF-8
2,938
3.390625
3
[]
no_license
use cat; use cat::*; /// Indicator struct for a key #[derive(Debug)] pub struct Key; /// Indicator struct for a value #[derive(Debug)] pub struct Value; /// Simple key/value pair #[derive(Debug, Copy, Clone)] pub struct Assignment { pub key_num: Num<Key>, pub value_num: Num<Value>, } /// Defines a numbering...
true
c35853df10028b57c30f8a8c4559c0cc85dc5c99
Rust
whatalnk/cpsubmissions
/atcoder/rust/abc044/abc044_a/3467211.rs
UTF-8
842
2.75
3
[]
no_license
// Contest ID: abc044 // Problem ID: abc044_a ( https://atcoder.jp/contests/abc044/tasks/abc044_a ) // Title: A. 高橋君とホテルイージー / Tak and Hotels (ABC Edit) // Language: Rust (1.15.1) // Submitted: 2018-10-25 09:57:14 +0000 UTC ( https://atcoder.jp/contests/abc044/submissions/3467211 ) use std::io; fn gets() -> String {...
true
193fe7667c97e86d09fd95ebd750e6664a3c01b5
Rust
harpsword/tex-rs
/src/tex_the_program/section_0106.rs
UTF-8
1,733
2.90625
3
[ "Apache-2.0", "MIT" ]
permissive
//! @ We also need to divide scaled dimensions by integers. // // @p function x_over_n(@!x:scaled;@!n:integer):scaled; pub(crate) fn x_over_n(globals: &mut TeXGlobals, mut x: scaled, mut n: integer) -> scaled { // var negative:boolean; {should |remainder| be negated?} /// should `remainder` be negated? let ...
true
ea1b553a8a7301c85b07ad67ec184240a1aeee91
Rust
yhoazk/vigilant-umbrella
/rust_thw/ex015.rs
UTF-8
7,104
3.484375
3
[]
no_license
use std::io::{File,FileAccess,IoResult,SeekStyle}; use std::io::FileMode::Open; use std::io::FileAccess::{Write,ReadWrite}; use std::fmt::{Show,Formatter,Error}; // Let's build a database // Set some constants. Note that the data type must be explicitly given const MAX_DATA: u16 = 512; const MAX_ROWS: u8 = 100; stru...
true
244ca9c83606e23d40a31bdc9e12def5b0aa14ef
Rust
marco-c/gecko-dev-wordified
/third_party/rust/tracing/src/field.rs
UTF-8
7,415
3.078125
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
/ / ! Span and Event key - value data . / / ! / / ! Spans and events may be annotated with key - value data referred to as known / / ! as _fields_ . These fields consist of a mapping from a key ( corresponding to / / ! a & str but represented internally as an array index ) to a [ Value ] . / / ! / / ! # Value s and Sub...
true
0dda8297f685be1ceea8b375bc1e48744d53d701
Rust
martinaAgata/21C1-Rust-eze
/src/commands/keys/expire.rs
UTF-8
2,817
3.21875
3
[]
no_license
use super::{no_more_values, parse_integer, pop_value}; use crate::database::Database; use crate::native_types::error_severity::ErrorSeverity; use crate::{ commands::Runnable, messages::redis_messages, native_types::ErrorStruct, native_types::{RInteger, RedisType}, }; use std::sync::{Arc, Mutex}; pub str...
true
e3d6ce072f98ab882256f8aae91b5543faa97eaa
Rust
tocklime/aoc-rs
/aoc/src/solutions/y2015/day10.rs
UTF-8
845
2.90625
3
[]
no_license
use aoc_harness::aoc_main; aoc_main!(2015 day 10, part1 [p1], part2 [p2]); use itertools::Itertools; use std::str::FromStr; fn step(input: &[usize]) -> Vec<usize> { let mut ans = Vec::new(); let mut pos = 0; while pos < input.len() { let c = input[pos]; let len = input[pos..].iter().take_w...
true
bc29b79978a486f39a40f98f8b5cac0195d35394
Rust
nikomatsakis/mutable
/src/vec.rs
UTF-8
2,814
3.375
3
[]
no_license
use crate::mcell::MCell; use std::vec::Vec; mod test; pub struct MutVec<T> { data: MCell<Vec<T>>, } impl<T> MutVec<T> { pub fn new() -> Self { Self::default() } pub fn len(&self) -> usize { self.data.borrow().len() } /// The equivalent of `self[index]` -- load the element at...
true
6be276855981b74bfd05757d0a5c9bf4b4506090
Rust
eugene-bulkin/nanodb-rust
/src/queries/plan_nodes/mod.rs
UTF-8
1,669
2.6875
3
[]
no_license
//! This module contains all plan nodes. mod file_scan; mod hashed_group_aggregate; mod project; #[cfg(test)] mod literal; mod nested_loop_join; mod rename; pub use self::file_scan::FileScanNode; pub use self::hashed_group_aggregate::HashedGroupAggregateNode; #[cfg(test)] pub use self::literal::LiteralNode; pub use s...
true
bd8aa386fa7e6bf6b97b1831f11ee7818c2d306b
Rust
yutiansut/Waffle
/src/heap/cms/atomic_list.rs
UTF-8
4,326
3
3
[ "Apache-2.0" ]
permissive
use crate::util::ptr::{DerefPointer, Ptr}; use std::sync::atomic::*; use std::sync::atomic::*; pub struct ListNode<T> { pub data: T, pub next: Ptr<Self>, } pub struct ListNodeIter<T> { focus: Ptr<ListNode<T>>, } impl<T: 'static> Iterator for ListNodeIter<T> { type Item = DerefPointer<T>; fn next(...
true
28307dbcb1054a4bf96b28cb0871115204bca784
Rust
typio/sorting-algorithms
/src/main.rs
UTF-8
3,494
2.734375
3
[]
no_license
#![windows_subsystem = "windows"] extern crate sdl2; use rand::{distributions::Uniform, Rng}; use sdl2::event::Event; use sdl2::keyboard::Keycode; use sdl2::mouse::MouseButton; use sdl2::pixels::Color; use sdl2::rect::{Point, Rect}; use std::time::Duration; use sdl2::gfx::primitives::DrawRenderer; fn new_array() ->...
true
76e0e9dfa4059ccfb666a163ffa001fa610da8b6
Rust
LEEDASILVA/rust
/init/change/src/main.rs
UTF-8
292
3.546875
4
[]
no_license
// Why does this code not compile fn main() { let ref mut a = String::from("Hello"); let len = a.len(); let b = &a; add_excitement(a); println!("The len of {} is {}", a, len); println!("The length of {} is {}", b, b.len()); } fn add_excitement(s: &mut String) { s.push_str("!"); }
true
9fb4fc09e1a403546dc9d13656aef0e4e8cc80e6
Rust
twoz/audio-stdout
/src/main.rs
UTF-8
3,715
2.65625
3
[]
no_license
extern crate portaudio; extern crate libc; #[macro_use] extern crate clap; use std::error::Error; use std::io::{stdout, Write}; use std::mem::size_of; use clap::{App, Arg, ArgMatches}; use portaudio::*; arg_enum! { enum SampleFormat { S16, S32, F32, } } struct Args { samplerate: Option<f64>, form...
true
b0462076d1c92c77fe50bdaa37ff3395044b0298
Rust
VonHeikemen/cmus-notify
/src/main.rs
UTF-8
2,000
3.375
3
[ "MIT" ]
permissive
use std::collections::HashMap; use std::env; use std::io::Error; use std::process::{Child, Command}; struct Notification { title: String, body: String, } impl Notification { fn new(args: HashMap<String, String>) -> Notification { fn not_empty(val: &&String) -> bool { !val.is_empty() ...
true
6f427b4f57d57d62a11f727e83759ca753f10e23
Rust
wfraser/pianoroll
/src/note.rs
UTF-8
3,215
2.875
3
[]
no_license
#[repr(u8)] #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Copy, Clone)] #[allow(dead_code)] // because the names are used for the Debug impl pub enum MidiNote { C1n = 0x00, Cs1n = 0x01, D1n = 0x02, Ds1n = 0x03, E1n = 0x04, F1n = 0x05, Fs1n = 0x06, G1n = 0x07, Gs1n = 0x08, A1n =...
true
132c8f3326fe0e3445869f057db99f3b0c349bef
Rust
PritiKumr/rust-httpd
/src/main.rs
UTF-8
7,103
2.6875
3
[]
no_license
use std::fs::File; use std::io::{BufRead, BufReader, Read, Write}; use std::net::{SocketAddr, TcpListener, TcpStream}; use std::process::Command; use std::str; use std::thread; extern crate httparse; fn respond_hello_world(mut stream: TcpStream) { let response = b"HTTP/1.1 200 OK\r\nContent-Type: text/html; chars...
true
a89623af5ae8332d10f739aa930c25559755fe07
Rust
smolkov/irrigatron
/src/gpio/mod.rs
UTF-8
7,451
2.515625
3
[]
no_license
use super::*; // use std::thread::sleep; use std::time::{Duration,SystemTime}; use async_std::prelude::*; use async_std::io; use async_std::fs; use async_std::task; // use linux_embedded_hal::Mio; use std::fmt; pub struct Mio { path: PathBuf, pin: u64, } #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum...
true
15f8f3e2b1dfb8bd2e18bfc94da0660fdfa090a9
Rust
PacktPublishing/The-Complete-Rust-Programming-Reference-Guide
/Chapter04/using_generic_func.rs
UTF-8
159
2.734375
3
[ "MIT" ]
permissive
// using_generic_func.rs use std::str; fn main() { let num_from_str = str::parse::<u8>("34").unwrap(); println!("Parsed number {}", num_from_str); }
true
244e6fce5946b8ccf9fdffd83e58de25c86fdb31
Rust
Ronnbreizh/gb
/src/gameboy/memory/memorybus.rs
UTF-8
7,036
2.703125
3
[]
no_license
use std::convert::TryInto; use std::fmt::format; use std::fs::File; use std::io::Read; use crate::gameboy::memory::{BANK_0_END, BANK_0_START, BANK_1_END, BANK_1_START, ECHO_RAM_END, ECHO_RAM_START, HIGH_RAM_END, HIGH_RAM_START, INTERRUPTS_REGISTER, IO_REGISTER_END, IO_REGISTER_START, SPRITE_TABLE_END, SPRITE_TABLE_STA...
true
78bfec4a03d571941013a6314a30d0134d4aafb9
Rust
eta077/jdn-echo
/echo-server/src/lib.rs
UTF-8
4,908
3.140625
3
[]
no_license
#![deny(missing_docs)] //! The simplest echo server use std::io; use std::io::Read; use std::net::SocketAddr; use std::net::TcpListener; use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::Arc; use std::thread; use std::time::Duration; /// A TCP server that echoes any message received from a client to all c...
true
8643a7bccb386f5439ef568bee1a131746a14b4b
Rust
afnanenayet/twitter-stream
/src/main.rs
UTF-8
775
2.65625
3
[]
no_license
mod config; mod sentiment; mod server; use serde_yaml; use std::{fs::File, io::BufReader}; use structopt::StructOpt; fn main() -> Result<(), anyhow::Error> { // First, get the config from a YAML file let opts = config::CliOpts::from_args(); let file = File::open(opts.config_file)?; let reader = BufRea...
true
463ae098b01433c8a2aa4f80676182b004ffe3b8
Rust
gvissers/babs
/tests/sub.rs
UTF-8
7,064
2.6875
3
[ "Apache-2.0" ]
permissive
// Copyright, 2021, Gé Vissers // // 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 agreed to in ...
true
0b5ad3365c16de6aba93ba470d9e2f7bc38da013
Rust
msyksphinz-self/dydra
/src/op_helper_fp_s.rs
UTF-8
14,613
2.640625
3
[ "MIT" ]
permissive
use softfloat_wrapper::{ExceptionFlags, Float, RoundingMode, F32}; use crate::target::riscv::riscv_csr::{CsrAddr}; use crate::emu_env::EmuEnv; impl EmuEnv { #[inline] fn convert_nan_boxing (i: u64) -> u32 { if i & 0xffffffff_00000000 == 0xffffffff_00000000 { (i & 0xffffffff) as u32 ...
true
aee8c462011de52b0495475542990486f47f1d19
Rust
jamesrweb/rust-coursework
/02 - Conditionals/05 - Ternary/main.rs
UTF-8
104
3.46875
3
[]
no_license
fn main() { let expression = if 2 > 1 { true } else { false }; println!("2 > 1 = {}", expression); }
true
c18d74409b37a4ab2b076b991e17465e49e2f404
Rust
nbari/cron-parser
/tests/tests.rs
UTF-8
8,787
2.859375
3
[ "BSD-3-Clause" ]
permissive
use chrono::{TimeZone, Utc}; use chrono_tz::{America::Chicago, US::Pacific}; use cron_parser::{parse, parse_field}; use std::collections::BTreeSet; macro_rules! parse_field_tests { ($($name:ident: $value:expr,)*) => { $( #[test] fn $name() { let (input, min, max, exp...
true
df028dd6724a6185702ab75965207c7766412498
Rust
youssefhabri/chip-8.rs
/src/display.rs
UTF-8
2,213
2.9375
3
[]
no_license
use sdl2::pixels::Color; use sdl2::rect::Rect; use sdl2::render::WindowCanvas; use sdl2::Sdl; pub struct Display { gfx: [[u8; 64]; 32], draw_flag: bool, canvas: WindowCanvas, } static SCALE: u32 = 20; impl Display { pub fn new(sdl_context: Sdl) -> Display { let video_subsystem = sdl_context.v...
true
32c4069689246369badca5fcb478bc0ed5fbda1e
Rust
say3no/try_rust
/tour/src/chapter5_ownership_and_borrow/tour51_delegate_borrowed_data.rs
UTF-8
1,321
3.671875
4
[]
no_license
struct Foo { x: i32, } fn do_something(f: &mut Foo) { f.x += 1; // f への可変な参照はここでドロップ } /* Rustの参照に関するルールは、以下のようにまとめられます。 * Rustでは、可変な参照が一つだけか、普遍な参照が複数かのどちらかが許可されます。 両方を同時には使用できません。 * 参照は、所有者よりも長く存在してはなりません。 これは、関数への参照を渡す際に問題となることはありません。 メモリの詳細: * 参照の最初のルールはデータ競合を防ぎます。 データ競合とは?データを読み込む際、データへの書き込みが同...
true
6cabcc62c30deafb4cb99da5098bdecf8b6f8065
Rust
maksym-pasichnyk/mcworld
/src/raw/encode.rs
UTF-8
514
2.9375
3
[]
no_license
use std::io::{Cursor, Write}; pub trait Encode { type Error; fn encode<T: Write>(&self, writer: &mut T) -> ::std::result::Result<(), Self::Error>; } pub fn encode_into_buffer<'a, 'b, T>( value: &'a T, buf: &'b mut [u8], ) -> ::std::result::Result<&'b mut [u8], T::Error> where T: Encode, { let ...
true
eceaf946f3cb9af2a58223e8a628a201e49169de
Rust
ericgroom/advent2019
/advent2019/src/day14.rs
UTF-8
13,574
3.1875
3
[]
no_license
use crate::utils::read::read_list; use std::collections::{HashMap, VecDeque}; use std::str::FromStr; type Quantity = usize; #[derive(PartialEq, Eq, Debug, Clone, Default)] struct ReactionItem { quantity: Quantity, id: String, } impl ReactionItem { fn new(quantity: Quantity, id: String) -> ReactionItem { ...
true
2ee4710709364fabff385f7d51a76f50e354ac6a
Rust
chromium/chromium
/third_party/rust/rustversion/v1/crate/src/release.rs
UTF-8
929
2.953125
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference", "BSD-3-Clause", "GPL-1.0-or-later", "LGPL-2.0-or-later" ]
permissive
use crate::error::{Error, Result}; use crate::iter::Iter; use crate::token; use proc_macro::Group; #[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord)] pub struct Release { pub minor: u16, pub patch: Option<u16>, } pub fn parse(paren: Group, iter: Iter) -> Result<Release> { try_parse(iter).map_er...
true
131d63245119fab00fed03a513b24be695511da2
Rust
decentninja/decent.ninja
/src/content.rs
UTF-8
1,644
2.828125
3
[]
no_license
extern crate serde; extern crate serde_json; use std::fs::File; use std::io::prelude::*; #[derive(Serialize, Deserialize)] struct Link { url: String, text: String, } #[derive(Serialize, Deserialize)] struct PortfolioPiece { id: String, image: String, title: String, isa: String, descript...
true
cc6407dda217816169cc3b582ee3c4b26295a060
Rust
paulcacheux/rlox
/compiler/src/ast_eval/error.rs
UTF-8
464
2.546875
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use std::{borrow::Cow, fmt}; use crate::{lexer::Span, ErrorSpannable}; #[derive(Debug)] pub struct EvalError { pub msg: Cow<'static, str>, pub span: Span, } impl fmt::Display for EvalError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "[span: {:?}] {}", self.span, self.ms...
true
c11c7d290d076d4fd5b448dda128a2b1b325e301
Rust
fossabot/rust-csp
/libsecsp/src/expr.rs
UTF-8
4,405
2.90625
3
[ "MIT" ]
permissive
use ast::*; use name::*; use security_attributes::*; named!(pub expr<&[u8], Expr>, alt_complete!( context | level_range | category_range | logical_or_expr ) ); macro_rules! binexp { ($name:ident, $next: ident, $op:path, $tag:expr) => { named!(pub $name<&[u8], Expr>, ws!(do_parse!( ...
true
760c49d3fc388780758bd8e066237aacb233c4e9
Rust
nsg/adventofcode
/2020/03/rust/part1.rs
UTF-8
510
3.0625
3
[]
no_license
use std::io::{self, BufRead}; fn main() { let lines: Vec<String> = io::stdin().lock().lines() .map(|line| line.unwrap().parse().unwrap()) .collect(); let mut x = 0; let mut c = 0; for line in lines { let line_c = line.chars().nth(x).unwrap(); if line_c.eq(&'#')...
true
be94ea5d0a35c1abc83119058300238a19b9751d
Rust
eliaslfox/rust-http
/parse/src/percent_encode.rs
UTF-8
4,966
2.984375
3
[]
no_license
use std::borrow::Cow; // A C0 control is a code point in the range U+0000 NULL to U+001F INFORMATION SEPARATOR ONE, inclusive. fn is_c0_control(c: char) -> bool { matches!(c, '\u{00}'..='\u{1F}') } // The C0 control percent-encode set are the C0 controls and all code points greater than U+007E (~). fn is_c0_contr...
true
c4ea6ac74d7b4f6984f2dbf61e14f3bef9401e51
Rust
jiayaoqijia/simple-json
/src/json.rs
UTF-8
11,157
2.984375
3
[ "Apache-2.0" ]
permissive
extern crate alloc; use alloc::{vec::Vec, string::String as AllocString}; use crate::parser::{ Concat, Concat3, Either, Error, Input, OneOf, OneOrMore, Parser, ResultOf, ZeroOrMore, ZeroOrOne, }; use crate::{ literals, parsers }; use core::{ convert::TryInto, fmt::Debug }; use num_traits::{ float::FloatCore };...
true
476d4c72ef6236dc5cc697d3acac288c531ee947
Rust
aghecenco/kcovsig
/src/main.rs
UTF-8
188
2.546875
3
[]
no_license
extern crate foobar; use foobar::*; fn main() { let fb = Foobar { foo: 42, bar: "asdf".to_string(), }; println!("Hello, world!"); println!("{:?}", fb); }
true
69ec1687ba7ed9b2a86b4ee8518b428180ec00b4
Rust
whatalnk/cpsubmissions
/atcoder/rust/abc075/abc075_a/3573785.rs
UTF-8
767
2.984375
3
[]
no_license
// Contest ID: abc075 // Problem ID: abc075_a ( https://atcoder.jp/contests/abc075/tasks/abc075_a ) // Title: A. One out of Three // Language: Rust (1.15.1) // Submitted: 2018-11-10 06:29:38 +0000 UTC ( https://atcoder.jp/contests/abc075/submissions/3573785 ) use std::io; fn gets() -> String { let mut buf = Stri...
true
e2336afb4b64b30676b54e228203b6b2c9ad5fb6
Rust
wotsushi/competitive-snippet
/snippets/graph/weighted_directed_graph/weighted_directed_graph.rs
UTF-8
1,875
2.671875
3
[ "MIT" ]
permissive
#![allow(non_snake_case)] #![allow(unused_variables)] #![allow(dead_code)] fn main() { let (_N, _M, r): (usize, usize, usize) = { let mut line: String = String::new(); std::io::stdin().read_line(&mut line).unwrap(); let mut iter = line.split_whitespace(); ( iter.next().u...
true
27253b1c2758d523acd2c132ca8ca20ba1bd754c
Rust
adalbertoteixeira/commit_message
/tests/commit_message.rs
UTF-8
673
2.546875
3
[]
no_license
use assert_cmd::prelude::*; // Add methods on commands use predicates::prelude::*; // Used for writing assertions use std::process::Command; // Run programs #[test] fn display_help() -> Result<(), Box<dyn std::error::Error>> { let mut cmd = Command::cargo_bin("commit_message")?; cmd.arg("--help"); cmd.ass...
true
4ce85ed750e9171a22c478dcf2c247c6deb18c57
Rust
johnellis1392/programming_problems
/project_euler/rust/src/pe_3.rs
UTF-8
485
3.46875
3
[]
no_license
use std::cmp::max; pub fn pe_3(x: u64) -> u64 { let mut n: u64 = x; let mut i: u64 = 2; let mut j: u64 = f64::sqrt(n as f64) as u64; 'outer: loop { for k in i..=j { if n % k == 0 { n = n / k; j = f64::sqrt(n as f64) as u64; continue 'outer; } } break; } retur...
true
94936ee87a88c70f61353dc17b81c73894690fd7
Rust
SaeedAnas/mal-cli
/rmal/src/api/manga.rs
UTF-8
3,708
2.78125
3
[]
no_license
use super::model::*; use super::Error; use super::{get, handle_response, API_URL}; use crate::auth::OAuth; use serde::Serialize; #[derive(Clone, Debug, Serialize)] pub struct GetMangaListQuery { pub q: String, pub limit: u64, pub offset: u64, pub nsfw: bool, #[serde(skip_serializing_if = "Option::i...
true
4195b1fd98fbd0c82e683334316d8a96fc92b710
Rust
isgasho/dotao
/src/diff.rs
UTF-8
4,554
3.015625
3
[ "BSD-3-Clause" ]
permissive
use std::{ fs, io, path::{Path, PathBuf}, }; use file_type_enum::FileType as FileTypeEnum; use tsml::FileTree; use crate::{ error, util::{self, to_utf}, }; #[derive(Debug, Default, Clone)] pub struct StatusDiff<'a> { // Ok stuff pub linked_correctly: Vec<&'a FileTree>, pub ready_to_link: ...
true
c5db0edda5f97104304f63a20425762653e2d69a
Rust
oOBoomberOo/json_peek
/src/lexer/token.rs
UTF-8
3,771
3.4375
3
[]
no_license
use crate::util::Span; use std::fmt; use std::str::FromStr; /// A single point of string that represent a useful symbol for [Parser](../parser/struct.Parser.html) to use #[derive(Clone, Copy, Eq)] pub struct Token<'a> { pub span: Span, source: &'a str, pub kind: TokenKind, } impl<'a> Token<'a> { pub const fn new(...
true
3d19ababfbd80e2ca693d9b85dff5bdd1d1fc531
Rust
kaikalii/cargo-stabilize
/src/main.rs
UTF-8
6,927
3.1875
3
[]
no_license
extern crate colored; extern crate toml; use std::{env, fs, process::Command}; use colored::*; fn get_version(crate_name: &str) -> Result<String, String> { if let Ok(resp) = Command::new("cargo").arg("search").arg(crate_name).output() { let resp_string = String::from_utf8_lossy(&resp.stdout) ...
true
ef6c10a10e0768ee2aaa9fff317daf3b8acfd7cd
Rust
azriel91/autexousious
/crate/asset_model/src/item_component.rs
UTF-8
650
3.015625
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
use amethyst::{ ecs::{Component, Entity}, shred::SystemData, }; /// An independent part of an item that may be loaded from an asset, such as `WaitSequenceHandles`. pub trait ItemComponent<'s>: Component { /// `SystemData` needed when augmenting an entity with `Component`s. type SystemData: SystemData<'...
true
38673fdb3e13e86b36a215c727e0eacad6fa8b3a
Rust
zhiburt/tabled
/tabled/examples/compact_table_3.rs
UTF-8
524
3
3
[ "MIT" ]
permissive
//! This example demonstrates how [`CompactTable`] is limited to single //! line rows. //! //! * Note how the multiline data is accepted, but then truncated in the display. use tabled::{settings::Style, tables::CompactTable}; fn main() { let data = [ ["De\nbi\nan", "1.1.1.1", "true"], ["Arch", "12...
true
1bfb3200170d7d1a118268076448a6ba390a1bf6
Rust
lineCode/tuix
/core/src/store/mod.rs
UTF-8
7,817
2.78125
3
[ "MIT" ]
permissive
#![allow(dead_code)] pub mod node; pub mod lens; use std::{any::TypeId, collections::HashSet}; pub use node::*; pub use lens::*; use crate::{IntoChildIterator}; use crate::{State, Entity, Event, Widget, Propagation, PropSet}; use crate::events::event_handler::Canvas; pub trait Model { fn on_event(&mut self, #[...
true
1c2f1d0fa190fdf29e79b76ad18a017dccd4d2b5
Rust
cloudevents/sdk-rust
/src/binding/http/serializer.rs
UTF-8
4,686
2.578125
3
[ "Apache-2.0" ]
permissive
use std::{cell::RefCell, rc::Rc}; use crate::binding::http::builder::Builder; use crate::binding::{ http::{header_prefix, SPEC_VERSION_HEADER}, CLOUDEVENTS_JSON_HEADER, }; use crate::event::SpecVersion; use crate::message::BinaryDeserializer; use crate::message::{ BinarySerializer, Error, MessageAttributeV...
true
043fab4679ba43e9c5e1243f8619c972bc9fdf10
Rust
paunstefan/sonar_rs
/sonar_client/src/main.rs
UTF-8
5,956
2.5625
3
[]
no_license
use std::error::Error; use std::net::UdpSocket; use std::sync::mpsc; use std::sync::mpsc::{Receiver, Sender}; use std::thread; use sonar_common::*; use fltk::{app, button::*, dialog::*, input::Input, output::*, prelude::*, window::Window}; mod state_machine; use state_machine::*; // TODO: drawing #[derive(Debug)]...
true
8aa6caf71b7a0a2c45231178681c6bf9dc21220d
Rust
celluloce/Rust
/Example/projects/Game/auto_guess/src/main.rs
UTF-8
1,068
3.796875
4
[]
no_license
extern crate rand; use std::cmp::Ordering; use rand::Rng; fn main() { auto_guess(); } fn auto_guess(){ println!("Guess the number!"); let secret_number = rand::thread_rng().gen_range(1, 101); println!("Please input your guess."); let mut guess = rand::thread_rng().gen_range(1, 101); ...
true
ebc4322e3d1f41f1f9c003ecac32ac20aa225ad3
Rust
38/grass-demo
/grass/src/chromset.rs
UTF-8
5,628
3.15625
3
[]
no_license
use std::{ borrow::{Borrow, Cow}, cell::UnsafeCell, cmp::Ordering, collections::HashMap, fmt::{Debug, Display, Formatter, Result as FmtResult}, io::Write, sync::Arc, }; pub trait WithChromSet<H: ChromSetHandle> { type Result; fn with_chrom_set(self, handle: &mut H) -> Self::Result; ...
true
9212e7b231512ca2893131502a9fbd304e0aefac
Rust
rust-bpf/rust-bcc
/src/core/perf_event_array/v0_4_0.rs
UTF-8
2,886
2.5625
3
[ "MIT" ]
permissive
use crate::cpuonline; use crate::types::MutPointer; use bcc_sys::bccapi::*; use std::collections::HashMap; use std::hash::{Hash, Hasher}; #[derive(Debug)] pub struct PerfEventArray { name: String, ev_type: u32, ev_config: u32, table_fd: i32, cpu_fd: HashMap<usize, i32>, } impl PerfEventArray { ...
true
569a6a8722d3c916858f1cffe38495f076033067
Rust
rust-web/twig
/src/lib.rs
UTF-8
2,744
2.796875
3
[ "BSD-3-Clause" ]
permissive
// This file is part of Twig (ported to Rust). // // For the copyright and license information, please view the LICENSE // file that was distributed with this source code. //! # Twig Templating for Rust //! //! **Work in progress** - This library is still in development and not yet ready for use. //! Take a look at th...
true
4258ec3cabf4dfd6e4529560df429cb658b2297e
Rust
karjonas/advent-of-code
/2017/day23/src/lib.rs
UTF-8
6,145
3.25
3
[]
no_license
use std::fs::File; use std::io::prelude::*; #[derive(Debug, Clone)] enum Instruction { Set0(usize, i64), Set1(usize, usize), Sub0(usize, i64), Sub1(usize, usize), Mul0(usize, i64), Mul1(usize, usize), Jnz0(usize, i64), Jnz1(usize, usize), Jmp(i64), } fn collect_instructions(cmds: V...
true
35331c964685371fc81b40f42a925d2d773a1dea
Rust
pjmore/arrow2
/src/array/fixed_size_binary/from.rs
UTF-8
3,819
3.15625
3
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
use core::iter::FromIterator; use alloc::sync::Arc; use super::FixedSizeBinaryArray; use crate::array::{Array, Builder, ToArray, TryFromIterator}; use crate::bitmap::MutableBitmap; use crate::buffer::MutableBuffer; use crate::{ datatypes::DataType, error::{ArrowError, Result as ArrowResult}, }; /// auxiliary ...
true
38c8520792a5b2449ca20d57d6dbf89075bfbb27
Rust
ryanleecode/rsqlite3
/src/main.rs
UTF-8
4,326
2.515625
3
[]
no_license
#![feature(trait_alias)] use rustyline::error::ReadlineError; use rustyline::Editor; mod ast; mod bptree; mod executor; mod pager; mod sqlite3; mod table; use bptree::BPTree; use lalrpop_util::ParseError; use ast::{Ast, Value}; fn main() { let mut rl = Editor::<()>::new(); rl.load_history("history.txt").ok...
true
f1d949a0f8948ee6e0c6564d55776669317cce37
Rust
gbersac/process_manager_42
/src/solver/resource_list.rs
UTF-8
1,747
2.9375
3
[]
no_license
use project::ProjectPtr; #[derive(Debug, Clone, PartialEq)] pub struct ResourceList { /// A list of size nb_resource with list[i] = number of resource which /// index is i. /// /// Resource of index 0 is time list: Vec<usize>, } impl ResourceList { pub fn new(list: Vec<usize>) -> ResourceList ...
true
e91c7f3bc7a6439b16d55eaf77d2641fba917ad6
Rust
Bert-Proesmans/medici
/medici_core/src/storage/entity.rs
UTF-8
993
3.171875
3
[ "MIT" ]
permissive
//! Module containing structures for storing entities. use function::{ArrayStorageCompliance, Entity}; #[derive(Debug, Clone)] /// Structure wrapping a [`Vec`] to provide a container for (all) entities /// within the state machine. pub struct EntityStorage<E> where E: Entity + Clone, E::ID: Into<usize> + From...
true
86f16252466e2e53060d22299c4b082c52edbc3b
Rust
stm32-rs/stm32-rs-nightlies
/stm32h5/src/stm32h503/hash/csr37.rs
UTF-8
2,108
2.5625
3
[]
no_license
#[doc = "Register `CSR37` reader"] pub type R = crate::R<CSR37_SPEC>; #[doc = "Register `CSR37` writer"] pub type W = crate::W<CSR37_SPEC>; #[doc = "Field `CS37` reader - Context swap x Refer to Section 24.7.7: HASH context swap registers introduction."] pub type CS37_R = crate::FieldReader<u32>; #[doc = "Field `CS37` ...
true
44f8b28f40e30bf04b19571ab98ecbb780688a20
Rust
JohnMurray/string-match
/src/test/string_match_test.rs
UTF-8
262
2.953125
3
[]
no_license
use qs_score::*; #[test] fn qs_should_return_09_for_empty_comprator_string() { assert!(qs_score("hello", "", 0) == 0.9f32); } #[test] fn qs_should_return_0_for_longer_comparator_string() { assert!(qs_score("short", "very very very long", 0) == 0f32); }
true
4858c101bbc196b96d3c4423accf920523809d13
Rust
RagePly/aoc16
/src/day4.rs
UTF-8
3,154
3.21875
3
[]
no_license
use std::fs; use std::collections::HashMap; use std::cmp::Ordering; #[allow(dead_code)] const FILENAME: &str = "data/day4.txt"; fn order_by_frequency(words: &[&str]) -> String { let mut freq_map: HashMap<char, i64> = HashMap::new(); for &word in words { for c in word.chars() { *freq_map.en...
true
46d0afe2c1d22a4bedc42c88ca65f279a1c555eb
Rust
bouzuya/rust-atcoder
/cargo-atcoder/contests/abc013/src/bin/b.rs
UTF-8
377
2.765625
3
[]
no_license
use proconio::input; fn main() { input! { a: i64, b: i64, }; let mut up = 0; for i in 1..10 { if (a + i) % 10 == b { up = i; } } let mut down = 0; for i in 1..10 { if (10 + a - i) % 10 == b { down = i; } } let a...
true
fed902fcb8611aaa10bc7e4fb536cb99981652a8
Rust
gitter-badger/kernel-2
/src/abstractions/streams/filter.rs
UTF-8
853
2.796875
3
[]
no_license
use abstractions::streams::stream::Stream; use abstractions::poll::{Async, Poll}; #[must_use = "streams do nothing unless polled"] pub struct Filter<S, F> { stream: S, f: F, } pub fn new<S, F>(s: S, f: F) -> Filter<S, F> where S: Stream, F: FnMut(&S::Item) -> bool { Filter { stream: s, f: ...
true
a8aac8a023069eed8c9b9f38e78c45ada91e13e8
Rust
mrtvfuencxozd/gfold
/src/lib.rs
UTF-8
8,577
3.0625
3
[ "Apache-2.0" ]
permissive
/* * gfold * https://github.com/nickgerace/gfold * Author: Nick Gerace * License: Apache 2.0 */ #[macro_use] extern crate prettytable; use std::cmp::Ordering; use std::fs; use std::path::Path; use std::path::PathBuf; use eyre::Result; /// Creating a ```Results``` object requires using this ```struct``` as a pr...
true