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
19c266b50054e6e1b7fe33e72476e61e7cb95fed
Rust
rustinio/rustin
/src/config.rs
UTF-8
695
3.53125
4
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
//! Configuration data for Rustin. /// Configuration data for a `Robot`. #[derive(Clone, Debug)] pub struct Config { /// An alias for the robot. /// /// The robot normally determines that a message is directed to it by looking for its username /// or display name at the beginning of a message. If an al...
true
b8e5d856054ba6c3a691cec52ed1a9efbce06b0f
Rust
monkeylyf/interviewjam
/math/leetcode_maximum_prodct_of_tree_numbers.rs
UTF-8
969
3.640625
4
[]
no_license
/** * Given an integer array, find three numbers whose product is maximum and * output the maximum product. * * Example 1: * Input: [1,2,3] * Output: 6 * * Example 2: * Input: [1,2,3,4] * Output: 24 * * Note: * The length of the given array will be in range [3,104] and all elements are * in the range [-10...
true
e7ca4732fefd9a88a33d52c1c21f25d0862dabd7
Rust
irwineffect/mcp795xx-rs
/src/datetime.rs
UTF-8
1,183
3.125
3
[ "MIT" ]
permissive
#[derive(Debug,Clone,Copy)] pub struct DateTime { pub seconds: u8, pub minutes: u8, pub hours: u8, pub weekday: u8, pub date: u8, pub month: u8, pub year: u16, } #[cfg(feature = "chrono")] use chrono::{Datelike, Timelike}; #[cfg(feature = "chrono")] impl From<chrono::naive::NaiveDateTime...
true
19b99cbe6829db6db71b31760570fdf1244de55a
Rust
nlopes/arq
/src/folder.rs
UTF-8
4,611
2.78125
3
[ "MIT" ]
permissive
use std; use std::collections::BTreeMap; use std::io::{BufRead, Cursor, Seek}; use plist; use crate::error::Result; use crate::object_encryption; use crate::type_utils::ArqRead; /// FolderData contains metadata information written every time a new Commit is created. /// /// It's a plist containing the previous and c...
true
ab01cbea2a207ef60b09a9712a36a5c72036344f
Rust
panicbit/marscalc
/src/number/addition.rs
UTF-8
785
3.3125
3
[]
no_license
use std::ops; use super::{Number, BASE}; impl ops::AddAssign for Number { fn add_assign(&mut self, mut other: Self) { if self.is_positive != other.is_positive { return *self -= -other; } self.equalize_with(&mut other); let digits_a = self.digits.iter_mut().rev(...
true
ed8d92c92b15e2e3c4cb94fcdfab4813be44588d
Rust
lukwol/iced-screen
/examples/greeting-app/screens/greeting/view.rs
UTF-8
1,239
2.6875
3
[ "MIT" ]
permissive
use iced::{Align, Button, Column, Container, Element, Length, Space, Text}; use iced_screen::message::{Message, NavigateMessage}; use crate::common::messages::{route::RouteMessage, screen::ScreenMessage}; use super::state::{Model, ViewState}; use rand::seq::SliceRandom; const GREETINGS: &[&str] = &["Bonjour", "Hola"...
true
2406c84864413913899f56aaac829e4f8fad2aba
Rust
elmarco/virtblocks
/rust/native/src/playground/toy.rs
UTF-8
1,985
3.1875
3
[ "MIT" ]
permissive
// Virt Blocks // // Copyright (C) 2019 Red Hat, Inc. // // This software is distributed under the terms of the MIT License. // See the LICENSE file in the top level directory for details. use std::error; use std::fmt; /// Possible error types for Toy #[repr(u32)] #[derive(Copy, Clone, Debug)] pub enum ToyError { ...
true
dd5161d59957a7535a388a9130fd44c029cb12b8
Rust
edglaz/kyopro
/atcoder/abc153A_serval_vs_monster.rs
UTF-8
381
2.9375
3
[ "BSD-3-Clause" ]
permissive
// unihernandez22 // https://atcoder.jp/contests/abc153/tasks/abc153_a // math use std::io::stdin; fn main() { let mut s = String::new(); stdin().read_line(&mut s).unwrap(); let words: Vec<i64> = s .split_whitespace() .map(|x| x.parse().unwrap()) .collect(); let h = words[0];...
true
e602f2f20e55d94741543845433e6d771c12953b
Rust
tehzz/n64disasm
/src/disasm/instruction.rs
UTF-8
4,056
2.75
3
[]
no_license
use crate::disasm::pass1::{FileBreak, JumpKind, LinkedVal}; use arrayvec::ArrayString; use capstone::{ arch::mips::MipsOperand::{self, *}, prelude::*, Insn, }; use err_derive::Error; use std::convert::TryInto; use std::fmt; #[derive(Debug, Error)] pub enum InsnParseErr { #[error(display = "MIPS opcode ...
true
28535a8e1934cf45d2710a11a18a84e4a86ad447
Rust
mhmoudgmal/sup
/src/localstack/aws/apigateway.rs
UTF-8
1,427
2.546875
3
[]
no_license
use std::error::Error; use colored::*; use log::*; use tokio::process::Command; use crate::stack::parser::AWSService; const LOCALSTACK_APIGATEWAY_ENDPOINT: &str = "http://localhost:4567"; pub async fn wait_for_it() -> Result<(), Box<dyn Error>> { let mut ready: bool = false; while !ready { warn!("w...
true
be04986057ce9fa3d1b3896036737b76b4e4d922
Rust
mozilla/gecko-dev
/third_party/rust/wasm-smith/src/component.rs
UTF-8
74,353
2.90625
3
[ "LicenseRef-scancode-unknown-license-reference", "LLVM-exception", "Apache-2.0" ]
permissive
//! Generation of Wasm //! [components](https://github.com/WebAssembly/component-model). #![allow(unused_variables, dead_code)] // TODO FITZGEN use crate::{arbitrary_loop, Config, DefaultConfig}; use arbitrary::{Arbitrary, Result, Unstructured}; use std::collections::BTreeMap; use std::convert::TryFrom; use std::{ ...
true
aa01874ad8f63d308dc08c8db23abf398b0f7b1b
Rust
dashaw92/euler-rs
/src/bin/p001.rs
UTF-8
231
3.734375
4
[]
no_license
// Problem 1 - Multiples of 3 and 5 // // Find the sum of all the multiples of 3 or 5 below 1000. fn main() { let result = (1..1000).filter(|&x| x % 3 == 0 || x % 5 == 0).fold(0, |acc, x| acc + x); println!("{}", result); }
true
eaa2cdc5b67b85d8542ab0757b82b25b10b3dbb0
Rust
gardrek/bollox
/src/scanner.rs
UTF-8
13,955
3
3
[]
no_license
use crate::result; use crate::source::{Source, SourceId, SourceLocation}; use crate::token::{string_as_reserved_word, Operator, Token, TokenKind}; use crate::INTERNER; fn is_identifier_start(c: char) -> bool { c.is_ascii_alphabetic() || c == '_' } fn is_identifier_continue(c: char) -> bool { c.is_digit(36) ||...
true
53fdf625fae561a190bf19ee84182b4f7d48b752
Rust
no111u3/rs_gui_experiments
/examples/hello.rs
UTF-8
1,744
3.0625
3
[ "Apache-2.0" ]
permissive
use gtk::prelude::*; use gtk::{Inhibit, Window, WindowType}; use relm::{connect, Relm, Update, Widget}; use relm_derive::Msg; struct Model { // ... } #[derive(Msg)] enum Msg { // ... Quit, } struct Win { // ... model: Model, window: Window, } impl Update for Win { // Specify the model us...
true
d51d04047b06ebb89ae21fa389b5cb314478d45f
Rust
matthewtgilbride/actor-interfaces
/messaging/rust/src/generated.rs
UTF-8
5,116
2.703125
3
[ "Apache-2.0" ]
permissive
extern crate rmp_serde as rmps; use rmps::{Deserializer, Serializer}; use serde::{Deserialize, Serialize}; use std::io::Cursor; #[cfg(feature = "guest")] extern crate wapc_guest as guest; #[cfg(feature = "guest")] use guest::prelude::*; #[cfg(feature = "guest")] pub struct Host { binding: String, } #[cfg(feature...
true
4b399e6983a8c78018c32d3e09ac0a112205f9e9
Rust
marco-c/gecko-dev-wordified
/third_party/rust/zip/tests/end_to_end.rs
UTF-8
7,280
2.75
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use byteorder : : { LittleEndian WriteBytesExt } ; use std : : collections : : HashSet ; use std : : io : : prelude : : * ; use std : : io : : { Cursor Seek } ; use std : : iter : : FromIterator ; use zip : : write : : FileOptions ; use zip : : { CompressionMethod SUPPORTED_COMPRESSION_METHODS } ; / / This test asserts...
true
d66aca6203dbeeac373412b1339c5ade99b7231d
Rust
tbrand/OutOfMemory
/oom-backend/oom-api/src/answers.rs
UTF-8
1,801
2.59375
3
[ "MIT" ]
permissive
use crate::api_error::api_error; use crate::db::answers; use crate::model::answers::*; use crate::state::State; use std::sync::{Arc, Mutex}; use warp::http::StatusCode; pub fn paginate( post_id: u32, state: Arc<Mutex<State>>, query: Query, ) -> Result<impl warp::Reply, warp::Rejection> { let conn = sta...
true
ac4a85b24b0fc81607072fb436f657b285624de0
Rust
DiveFish/ambiguity-stats
/src/tp_fp_fn.rs
UTF-8
17,919
2.71875
3
[]
no_license
use conllx::Token; use std::collections::HashMap; use std::vec::Vec; use scores::*; /// Calculate from a corpus the number of true positives, /// false positives and false negatives under a criterion /// given by the passed-on function. pub fn prec_rec_f1( gold_sents: &Vec<Vec<Token>>, parser_sents: &Vec<Vec...
true
e838985c01ddddf85b9d8572ba41526d8e5a3b0e
Rust
AustinJ235/vulkano
/vulkano/src/pipeline/layout.rs
UTF-8
57,563
2.96875
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
5645684f807227011414a40f77955f1124063b5c
Rust
kgtkr/procon
/atcoder/rust/xmascon17_a/src/main.rs
UTF-8
3,017
3.09375
3
[]
no_license
extern crate hound; fn main() { let list = read_files(); print!("{}\t\t", "答え"); answer(&list); println!(); print!("{}\t", "階差数列の絶対値の和"); diff(&list); println!(); print!("{}\t", "絶対値の分散"); variance(&list); println!(); print!("{}\t", "絶対値の合計"); sample_sum(&list); ...
true
99752b367d8bc0a65367d47b25ecf1cc3f5eda7b
Rust
arnau/heidi
/src/error.rs
UTF-8
653
2.90625
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
// Copyright 2020 Arnau Siches // Licensed under the MIT license <LICENCE or http://opensource.org/licenses/MIT>. // This file may not be copied, modified, or distributed except // according to those terms. use std::error::Error; use std::fmt; /// Represents an error after validating the integrity of a number. #[der...
true
88e5fa0b353239857eb933d2a23e58fc700caf7f
Rust
lilinghai/worklog
/rust/examples/guessing_game/src/main.rs
UTF-8
467
3.71875
4
[]
no_license
use std::io; fn main() { //macro not function ! //; represent the statement ends println!("Guess the number"); println!("Pls input your guess."); //variable default is inmutable; mut means mutable //String::new() is standard lib let mut guess = String::new(); //read_line() return io...
true
03327a34ecc5da42c15eb0cb323bfee3274f7ece
Rust
HiDefender/ferric
/test/daikon/simple1/main.rs
UTF-8
169
3.25
3
[ "MIT" ]
permissive
fn main() { let mut x: i32 = 5; let mut y: bool = true; x = squar(x, y); y = false; x = squar(x, y); } fn squar(x: i32, y: bool) -> i32 { x*x; }
true
602433a01b64096def1968a9d50e07bc94591143
Rust
probe-rs/itm-tracer
/src/runner.rs
UTF-8
3,665
2.65625
3
[]
no_license
use scroll::Pread; use serde::{Deserialize, Serialize}; use probe_rs::itm::{Decoder, TracePacket}; use probe_rs::Session; use crate::config::CONFIG; use crate::updater::{Updater, UpdaterChannel, WebsocketUpdater}; #[derive(Debug, Serialize)] enum Update { Packet(TracePacket), } #[derive(Debug, Deserialize)] enu...
true
6ec0d9cd76a1c3a79967584ab18052218621f897
Rust
katharostech/parry
/src/shape/capsule.rs
UTF-8
3,720
3.234375
3
[ "Apache-2.0" ]
permissive
use crate::math::{Isometry, Point, Real, Rotation, Vector}; use crate::shape::{Segment, SupportMap}; use na::Unit; #[derive(Copy, Clone, Debug)] #[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))] /// A capsule shape defined as a round segment. pub struct Capsule { /// The axis and endpoint of...
true
232872163a924998446c6d57b5dd312e6dc16217
Rust
data-niklas/cash2
/backend/src/values/list.rs
UTF-8
9,900
3.1875
3
[ "BSD-3-Clause" ]
permissive
use crate::error::CashError; use crate::value::{Value, ValueResult}; use crate::values::{BooleanValue, IntegerValue, RangeValue}; #[derive(Debug)] pub struct ListValue { pub values: Vec<Box<dyn Value>>, } impl ListValue { pub fn boxed(values: Vec<Box<dyn Value>>) -> ValueResult { Ok(Box::new(ListValue...
true
d256598f3e3a93a95cc1ad734daebeb0a9d603a8
Rust
zshipko/ocaml-rs
/sys/src/alloc.rs
UTF-8
1,259
2.53125
3
[ "ISC" ]
permissive
//! External definitions for allocating values in the OCaml runtime use crate::{ mlvalues::{Size, Value}, tag::Tag, Char, }; extern "C" { pub fn caml_alloc(size: Size, tag: Tag) -> Value; pub fn caml_alloc_small(size: Size, tag: Tag) -> Value; pub fn caml_alloc_tuple(size: Size) -> Value; ...
true
2b9b56c24f1d492bf035f3e354e3b24aeb85c485
Rust
Mark80/rust-projects
/blockchain/src/main.rs
UTF-8
1,074
3.375
3
[]
no_license
use crypto_hash::{Algorithm, hex_digest}; use std::ops::Add; #[derive(Debug)] struct Block<'a> { pointer: Option<&'a Block<'a>>, prev_hash: Option<String>, data: String, } fn main() { let block1 = Block { pointer: None, prev_hash: None, data: String::from("primo"), }; ...
true
23ab0cb771b55831ce8600bc9963956b1a2c3cab
Rust
evaporei/design-patterns
/behavioral/chain_of_responsibility/rust/src/lib.rs
UTF-8
2,514
3.359375
3
[]
no_license
#[derive(Debug, PartialOrd, PartialEq)] pub enum Level { Info = 1, Debug = 2, Error = 3, } pub trait AbstractLogger { fn set_next_logger(&mut self, abstract_logger: Box<AbstractLogger>); fn level(&self) -> &Level; fn next_logger(&self) -> &Option<Box<AbstractLogger>>; fn log_message(&self, ...
true
d0c27567b8494f2932e6d203e7fefc68ec966ddc
Rust
rskew/autonomic-rust
/src/proposal/interpreter.rs
UTF-8
15,774
2.890625
3
[]
no_license
use rusqlite; use std::fmt; use nomic_db; use utils::remove_punctuation; use proposal; use proposal::Proposal; //const ARTICLES: [&str; 8] = ["to", "the", // "rule", "of", // "too", "for", // "at","off"]; //const TRANSMUTE_WORDS: [&...
true
80af96029cb2a2a061abc8079e5728c4a07263f4
Rust
IThawk/rust-project
/rust-master/src/test/ui/empty/empty-struct-braces-pat-2.rs
UTF-8
650
2.671875
3
[ "MIT", "LicenseRef-scancode-other-permissive", "Apache-2.0", "BSD-3-Clause", "BSD-2-Clause", "NCSA" ]
permissive
// Can't use empty braced struct as enum pattern // aux-build:empty-struct.rs extern crate empty_struct; use empty_struct::*; struct Empty1 {} fn main() { let e1 = Empty1 {}; let xe1 = XEmpty1 {}; match e1 { Empty1() => () //~ ERROR expected tuple struct/variant, found struct `Empty1` } ...
true
1bea79e634882d8e24ee42140a5eaa53f6ad6d0e
Rust
eduhenke/yolm
/src/main.rs
UTF-8
2,492
3.109375
3
[]
no_license
use cursive::traits::*; use cursive::views::{Dialog, EditView, LinearLayout, TextView}; use cursive::Cursive; mod auth; mod sway; // YoLM - a simple program that requests user's name and password, logins and spawn sway // // Note that this proto-"sudo" is very insecure and should not be used in any production setup, /...
true
3415b8e28f36bcdf0037190d5ffcd3d009842b94
Rust
Happy-Ferret/combustion
/combustion_protocols/src/texture/data/texture.rs
UTF-8
3,177
3.640625
4
[]
no_license
//! Data structures for manipulating textures use ::texture::protocol::TextureKind; use ::blob::Blob; use super::format::SpecificFormat; /// Represents the variations of textures that can be used #[derive(Clone, Serialize, Deserialize)] #[serde(untagged)] pub enum RootTexture { /// Cubemap variant #[serde(re...
true
c0fa8f1cd4f04b2d4f17c1ee30fe2791410b7cf1
Rust
mrillusi0n/rust-beginner
/vectors.rs
UTF-8
172
3.03125
3
[ "MIT" ]
permissive
fn main() { let mut nums = vec![1, 2, 3, 4, 5, 6]; for num in &mut nums { *num *= 2; } for num in nums { println!("{}", num); } }
true
251c9a7a154e915d4bffe0259651b6cfedb939ca
Rust
alanpoon/conrod_thread
/src/custom_widget/chatview_ownedmsg.rs
UTF-8
7,201
3.109375
3
[]
no_license
use conrod::{self, widget, Colorable, Labelable, Positionable, Widget, image, Sizeable, Rect, color}; use self::widget::id::Generator; use itertools::multizip; use dyapplication; use custom_widget::custom_button; use std::collections::VecDeque; use std::sync::mpsc; /// The type upon which we'll implement the `Widget` t...
true
c21333ec687f315b1f5aed2b208aeb698ecfaea8
Rust
Mebus/nalgebra
/nalgebra-glm/src/gtx/exterior_product.rs
UTF-8
186
2.640625
3
[ "BSD-3-Clause", "BSD-2-Clause" ]
permissive
use crate::aliases::TVec2; use crate::traits::Number; /// The 2D perpendicular product between two vectors. pub fn cross2d<N: Number>(v: &TVec2<N>, u: &TVec2<N>) -> N { v.perp(u) }
true
bc01d54f8a3284d34aff10d5b0c60d3c48afd5b0
Rust
gitter-badger/ocl
/src/standard/buffer.rs
UTF-8
40,810
2.640625
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! Interfaces with a buffer. // [TEMP]: #![allow(dead_code)] use std; use std::marker::PhantomData; use std::ops::{Deref, DerefMut}; use ffi::cl_GLuint; use core::{self, OclPrm, Mem as MemCore, CommandQueue, MemFlags, MemInfo, MemInfoResult, ClEventPtrNew, ClWaitList, BufferRegion, MappedMem as MappedMemCore, ...
true
6972ed0baa51a6f1c6f73d08a23a5cd6a0e4571d
Rust
jFransham/test-game-rs
/src/physics.rs
UTF-8
985
3.03125
3
[]
no_license
use graphics::math::Vec2d; #[derive(Clone)] pub enum Shape { Rectangle { width: f64, height: f64 }, Circle { radius: f64 }, } #[derive(Clone)] pub enum CollisionType { Kinematic { trigger: bool }, Static { trigger: bool }, Dynamic, } #[derive(Clone)] pub enum BodyDef { Collide { shape...
true
5d732adee2761f573b384b995a29028bec3258d0
Rust
nossrannug/adventofcode
/rust/day_3/src/main.rs
UTF-8
1,476
3.296875
3
[]
no_license
use common::get_file_content; use std::env; fn main() { let args: Vec<String> = env::args().collect(); let contents = get_file_content(args.last().expect("Failed to get args").to_string()) .expect("Failed to get file content"); println!("Part 1: {}", part_1(&contents)); println!("Part 2: {}", p...
true
7f3dd79178bac31f9a1fc33ae6a84e37aa5d2c23
Rust
AlexanderThaller/advent_of_code_2020
/src/day03/mod.rs
UTF-8
1,697
3.140625
3
[]
no_license
use thiserror::Error; mod rider; #[derive(Debug, Error)] pub enum Error { #[error("can not read map: {0}")] MapError(#[from] rider::map::Error), } pub fn run() -> Result<(), Error> { println!("day_03::part_1: trees_seen = {}", part_1()?); println!("day_03::part_2: total trees_seen = {}", part_2()?); ...
true
3b951a5d916a4605dd82767e8b7ab52fcc49c316
Rust
linpingchuan/pingchuan-mq
/tests/test_parser.rs
UTF-8
1,101
2.84375
3
[ "MIT" ]
permissive
#[test] fn test_serialize_event(){ struct Mystruct{ id:u8, data:[u8;1024] } let my_struct=Mystruct{id:0,data:[1;1024]}; let bytes:&[u8]=unsafe{pingchuan::parser::PingchuanParser::any_as_u8_slice(&my_struct)}; println!("{:?}",bytes) } #[test] fn test_my_serializer(){ let mut byte...
true
e16f859a6e722ac2631a10a36d2826c44bde6f8f
Rust
Cenze94/SudokuSolver
/Rust/sudoku_solver/src/CheckSudokuMethods/mod.rs
UTF-8
4,364
3
3
[]
no_license
extern crate crossbeam; use crossbeam::crossbeam_channel::{Sender, bounded}; use super::SudokuManager::{sudoku, contains}; use super::SudokuIOManager::sudokuIOManager; // Check if there are cells without definitive values pub fn checkSudokuIsComplete(ioManager: &sudokuIOManager) -> bool { for i in 0..9 { f...
true
80a74eabab60e221617de8b0605ee9fdb5c9595b
Rust
en/clrs
/src/ch02/mod.rs
UTF-8
2,653
3.34375
3
[ "Unlicense" ]
permissive
use std::cmp; pub mod insertion_sort; pub mod linear_search; pub mod binary_add; pub mod selection_sort; pub mod merge_sort; pub mod binary_search; pub mod bubblesort; pub mod inversions; #[derive(Debug, Copy, Clone)] pub enum Value<T> { NegInfinity, Some(T), Infinity, } impl<T> PartialEq for Value<T> ...
true
d03e5f0f86c470948e7dd38d248bacd7c2aa7705
Rust
timothyjrogers/tjr-advent-of-code-solutions
/2021/DAY14/part2/src/main.rs
UTF-8
2,888
3.09375
3
[]
no_license
use std::fs::File; use std::io::{BufReader, BufRead}; use std::collections::HashMap; use std::borrow::Borrow; const FNAME: &str = "../data/input.txt"; fn main() { let f = File::open(FNAME).expect("Unable to open data file"); let reader = BufReader::new(f); let lines: Vec<String> = reader .lines() ...
true
25195844c2e116ee8fc3011acfc0e6f4ae02f388
Rust
Dimkar3000/exercism
/rust/nth-prime/src/lib.rs
UTF-8
544
3.078125
3
[ "MIT" ]
permissive
pub fn nth(a : usize) -> Result<i32,i32>{ if a < 1{ return Err(0); } let mut result: Vec<i32> = vec![2]; let mut inc = 1; let mut f:bool; while result.len() < a{ inc += 2; f = false; for i in result.iter(){ if inc % *i == 0 { f = true;...
true
0a08604de4cde93f31a148f7732f7340c8aac978
Rust
jolestar/libra
/types/src/validator_verifier.rs
UTF-8
23,762
2.609375
3
[ "Apache-2.0" ]
permissive
// Copyright (c) The Libra Core Contributors // SPDX-License-Identifier: Apache-2.0 use crate::{account_address::AccountAddress, on_chain_config::ValidatorSet}; use anyhow::{ensure, Result}; use libra_crypto::{ ed25519::{Ed25519PublicKey, Ed25519Signature}, HashValue, VerifyingKey, }; use mirai_annotations::*;...
true
9a5ae6f5b3f4c9a2123d9610f583ecefbdf18dca
Rust
sigmaSd/escape
/src/exe.rs
UTF-8
878
2.9375
3
[ "MIT" ]
permissive
use std::io::{self, Read}; use std::process::{Child, Command, Stdio}; pub fn execute(cmd: &str) -> io::Result<String> { let mut mem = None; for c in cmd.split('|') { mem = Some(run(mem, c)?); } let mut s = String::new(); mem.unwrap().stdout.unwrap().read_to_string(&mut s)?; Ok(s) } fn...
true
51602c1e17f47884139d09a65b9a26cd842eab2c
Rust
seanchen1991/ghost-collections
/src/linked_list/cursor.rs
UTF-8
15,405
3.28125
3
[ "Apache-2.0", "MIT" ]
permissive
use ghost_cell::GhostToken; use super::{GhostNode, LinkedList}; #[cfg(feature = "experimental-ghost-cursor")] use ghost_cell::GhostCursor; #[cfg(feature = "experimental-ghost-cursor")] use super::Node; /// A Cursor over the LinkedList. pub struct Cursor<'a, 'brand, T> { token: &'a GhostToken<'brand>, node: ...
true
6da90e6f3a485f5349a2d414877b408c5a8b2a05
Rust
coopersimon/modscript
/src/parser/tokeniser.rs
UTF-8
9,252
2.671875
3
[]
no_license
use super::Token; use error::{Error, Type, CompileCode}; use nom::{multispace, alphanumeric, alpha, digit}; pub fn tokenise(input: &str) -> Result<Vec<Token>, Error> { match p_token_list(input) { Ok((_,o)) => Ok(o), //Err(e) => Err(format!("Error: {:?}", e)), Err(_) => Err(Error::new(Type:...
true
2d74dd97024e2d15febfe1e28cd554345076e247
Rust
sirkibsirkib/expr_sites
/src/network.rs
UTF-8
906
2.5625
3
[]
no_license
use super::*; use std::sync::Arc; pub(crate) struct NetworkImpl { outboxes: Arc<HashMap<SiteId, Sender<Msg>>>, inbox: Receiver<Msg>, } impl NetworkImpl { pub fn new(outboxes: Arc<HashMap<SiteId, Sender<Msg>>>, inbox: Receiver<Msg>) -> Self { Self { outboxes, inbox } } } impl Network for Network...
true
8b8d5286e3ec78eac4f76fd2dd2d15c6db0c25b3
Rust
bouzuya/rust-atcoder
/cargo-atcoder/contests/abc125/src/bin/b.rs
UTF-8
329
2.609375
3
[]
no_license
use proconio::input; fn main() { input! { n: usize, v: [usize; n], c: [usize; n], }; let ans = v .iter() .copied() .zip(c.iter().copied()) .filter(|(v_i, c_i)| v_i > c_i) .map(|(v_i, c_i)| v_i - c_i) .sum::<usize>(); println!("{}",...
true
fea65dad8e63ee41df4e1494ddc0a49bf9508298
Rust
mmorga/life-piston-rust
/src/game_of_life.rs
UTF-8
3,597
3.484375
3
[]
no_license
#[repr(u8)] #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum Cell { Dead = 0, Alive = 1, } pub struct Universe { pub width: u32, pub height: u32, cells: Vec<Cell>, pub live_cells: Vec<(u32, u32)>, } impl Universe { fn get_index(&self, row: u32, column: u32) -> usize { (row * s...
true
8b68b22ff109f3d0c112b31bae9305a9101c9d63
Rust
RonaldColyar/DirGuardian
/src/sockethandler.rs
UTF-8
1,243
3.140625
3
[ "MIT" ]
permissive
use std::io::prelude::*; use std::net::TcpStream; use std::option::Option; use std::result::Result; use std::str::from_utf8; pub struct SockHandler{ pub sock :Option<TcpStream> //pub for tests } impl SockHandler{ pub fn new() -> Self{ Self{ sock:None } } pub fn connect(...
true
73f8ea5d103070394d8add32fda8363ab021a772
Rust
pupapaik/Mayastor
/mayastor/src/bdev/util/uring.rs
UTF-8
2,599
2.796875
3
[ "Apache-2.0" ]
permissive
use std::{ fs, fs::{File, OpenOptions}, io::{BufRead, BufReader, ErrorKind}, os::unix::fs::{FileTypeExt, OpenOptionsExt}, }; pub fn fs_supports_direct_io(path: &str) -> bool { // SPDK uring bdev uses IORING_SETUP_IOPOLL which is usable only on a file // descriptor opened with O_DIRECT. The file...
true
443e3690a1b9be14dd71fda66b9aec2a37a147e8
Rust
mfs/aoc-2020
/src/bin/p13.rs
UTF-8
1,378
3.25
3
[]
no_license
use anyhow::Result; use std::io::{self, BufRead}; fn main() -> Result<()> { let mut lines = vec![]; for line in io::stdin().lock().lines() { lines.push(line?); } let timestamp: u64 = lines[0].parse()?; let ids: Vec<u64> = lines[1].split(',').map(|x| x.parse().unwrap_or(0)).collect(); ...
true
a7edd656544e50b2a9bf7ba20278987be4a8c820
Rust
GuillaumeDIDIER/C-teel
/src/ltl/builder.rs
UTF-8
7,577
2.71875
3
[]
no_license
use ertl; use ltl::*; use common::label::LabelAllocator; use std::collections::HashMap; use common::ops::*; impl File { pub fn from_ertl(ertl_file: ertl::File) -> File { let functions = ertl_file.functions.into_iter().map( |ertl_func| { FuncDefinition::from_ertl(ertl_func) ...
true
dbec01f0aa9bc2ca2a8d277741d428e680522a01
Rust
kodek16/rs-view-tracker
/src/main.rs
UTF-8
2,767
2.703125
3
[ "MIT" ]
permissive
extern crate chrono; extern crate chrono_tz; extern crate futures; extern crate hyper; extern crate toml; #[macro_use] extern crate serde_derive; mod config; use std::fs; use std::net::{SocketAddr, IpAddr, Ipv4Addr}; use std::path::Path; use std::thread; use std::io::Write; use chrono::Utc; use chrono_tz::Tz; use...
true
e67eee49d306097965a8d72d9688e2057777b6d1
Rust
jgrosso/mandelbrot-rs
/src/main.rs
UTF-8
2,534
3.171875
3
[]
no_license
extern crate image; use image::ImageBuffer; use std::u8; static MAX_ITERATIONS: u16 = 10000; static PALETTE_SIZE: u16 = 40; static SCREEN_HEIGHT: u16 = 16384; static SCREEN_WIDTH: u16 = 16384; struct Interval { lower_bound: f32, upper_bound: f32, } impl Interval { fn range(&self) -> f32 { self....
true
2ec136e529370ee7e9dd348f7b8028ddaffb505b
Rust
Corallus-Caninus/windows-rs
/src/core/hresult.rs
UTF-8
3,335
2.78125
3
[]
no_license
use super::*; use bindings::{Windows::Win32::Foundation::PWSTR, Windows::Win32::System::Diagnostics::Debug::*}; /// A primitive error code value returned by most COM functions. #[repr(transparent)] #[derive(Copy, Clone, Default, Debug, Eq, PartialEq)] #[must_use] #[allow(non_camel_case_types)] pub struct HRESULT(pub u...
true
33615c0fa7d354072eba5197844c73238a7fcc66
Rust
dtolnay/linkme
/impl/src/args.rs
UTF-8
708
2.859375
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use syn::parse::{Error, Parse, ParseStream, Result}; use syn::{LitInt, Path, Token}; pub enum Args { None, Path(Path), PathPos(Path, usize), } impl Parse for Args { fn parse(input: ParseStream) -> Result<Self> { if input.is_empty() { return Ok(Args::None); } let pat...
true
6b73deb151021b9a3edd20030eda4ece5d6bb3c4
Rust
chromium/chromium
/third_party/rust/rstest/v0_17/crate/tests/resources/rstest/matrix/partial.rs
UTF-8
1,116
2.859375
3
[ "MIT", "Apache-2.0", "GPL-1.0-or-later", "LGPL-2.0-or-later", "BSD-3-Clause" ]
permissive
use rstest::*; #[fixture] fn f1() -> u32 { 0 } #[fixture] fn f2() -> u32 { 0 } #[fixture] fn f3() -> u32 { 0 } #[fixture] fn fixture(f1: u32, f2: u32, f3: u32) -> u32 { f1 + f2 + 2 * f3 } #[rstest(a => [0, 1], b => [0, 2])] fn default(fixture: u32, a: u32, b: u32) { assert_eq!(fixture, a * b); } ...
true
644f9a9bcd2c455da59425b631b19c9710fdd095
Rust
petar-dambovaliev/darpi
/darpi-code-gen/src/logger.rs
UTF-8
8,542
2.734375
3
[]
no_license
use logos; use logos::Logos; use proc_macro2::Span; use quote::quote; use syn::{Error, ExprLit, ItemStruct, Lit}; #[derive(Logos, Debug, PartialEq)] pub enum ReqFmtTok { #[token("%a")] RemoteIP, #[token("%t")] When, #[token("%u")] Url, #[token("%b")] BodySize, #[regex("%[{][A-Z]...
true
69ebc480235115f706c6f86352228643b2f3265b
Rust
Adrodoc/lmu-wise-2020-2021-rust-ue4
/src/main.rs
UTF-8
953
3.296875
3
[]
no_license
use clap::{App, Arg}; use std::collections::BTreeMap; const TEXT: &str = "text"; const SEPERATOR: &str = "seperator"; fn main() { let matches = App::new("ue4") .arg(Arg::with_name(TEXT) .short("t") .long("text") .help("The text to split using the seperator") ...
true
0bbdbb24cb2a867a19be6e6631fcef679ee78bf5
Rust
rowanhill/aoc20
/day07/src/main.rs
UTF-8
2,643
2.96875
3
[]
no_license
use std::collections::{HashSet, HashMap}; use std::io::{BufReader, BufRead}; use std::fs::File; use lazy_static::lazy_static; use regex::Regex; lazy_static! { static ref RULE_RE: Regex = Regex::new(r"(?:^(?P<parent>.+?) bags contain)|(?:(?P<num>\d+) (?P<colour>.+?) bags?)").unwrap(); } fn main() { let reader ...
true
d2bfd7e47df44c3d54a25f81c260cf593ce087cf
Rust
19h/rust-htr-detect
/src/main.rs
UTF-8
3,319
2.640625
3
[]
no_license
use biquad; use biquad::{Biquad, ToHertz, Hertz}; use std::default::Default; mod stats; use stats::Stats; use smoothed_z_score::{Peak, PeaksDetector, PeaksFilter}; use sample; use sample::Signal; struct HT<'a> { // Fractioning // Fs frame_size: f64, // frac interval: f64, // Band-pass fi...
true
6ca195d6dd721b7ab335af5a151c31a18b3ba9a8
Rust
Lucky3028/no-free-lunch
/src/main.rs
UTF-8
3,896
2.703125
3
[ "MIT" ]
permissive
use std::{env, sync::Arc}; use serenity::{ async_trait, builder::CreateEmbed, model::{channel::Message, gateway::Ready, id::ChannelId}, prelude::{Context, EventHandler}, Client, }; use tokio::sync::RwLock; use no_free_lunch::{util::DiscordEmbedExt, Config, GlobalConfigs}; struct Handler; #[async...
true
98335389c88bc93633167c86b7acc4b79d3cb69d
Rust
diegooliveira/mesosphere
/src/arguments.rs
UTF-8
4,608
3.546875
4
[]
no_license
#[derive(Debug)] pub struct Arguments { args: Vec<ArgValue>, flags: Vec<String>, command: Option<String>, parameters: Vec<String>, } #[derive(Debug, Clone)] pub enum ValueArgument { Supplied(String), MissingValue, NotSupplied } #[derive(Debug, Clone)] pub struct ArgValue { pub name: ...
true
fe765f6f52b18b8fb3a2c6fd3a97eedb5dfbeb39
Rust
RustWorks/butane
/examples/getting_started/src/models.rs
UTF-8
1,208
2.9375
3
[ "LicenseRef-scancode-unknown-license-reference", "Apache-2.0", "MIT" ]
permissive
use butane::prelude::*; use butane::{model, ForeignKey, Many, ObjectState}; #[model] #[derive(Debug, Default)] pub struct Blog { #[auto] pub id: i64, pub name: String, } impl Blog { pub fn new(name: impl Into<String>) -> Self { Blog { name: name.into(), ..Default::defaul...
true
08b41f3b155bd6871cc84401677789f2d376aa7d
Rust
ricmzn/dcs-hemmecs
/src/windows/mod.rs
UTF-8
1,721
2.71875
3
[ "MIT" ]
permissive
pub mod control_window; pub mod hmd_window; use std::ffi::CString; use std::ptr::null_mut as NULL; use std::sync::atomic::{AtomicBool, Ordering::Relaxed}; use winapi::um::winuser::{MessageBoxA, IDOK, MB_ICONERROR, MB_ICONINFORMATION}; use winapi::{ shared::windef::HWND, um::winuser::{GetSystemMetrics, SM_CXSCR...
true
77399c2b0ad55e926aa15660f14e4f4fd312d58b
Rust
monocodus-demonstrations/flowbetween
/build-broken.rs
UTF-8
2,273
2.65625
3
[ "Apache-2.0" ]
permissive
extern crate pkg_config; use pkg_config::*; use std::io::prelude::*; use std::io; // So, I'd quite like to persuade cargo to auto-detect which UI framework to use based on a build.rs script, but it doesn't seem to be // possible to use features defined here to change the set of dependencies (eg, disabling gtk-ui), s...
true
683dec9be52d383bfdd64e60d0404ac67f665b7f
Rust
CoderCharmander/rustone
/rshttp/src/communication.rs
UTF-8
518
2.5625
3
[ "MIT" ]
permissive
use openssl::{pkey::Private, rsa::Rsa}; use rand::*; use rustone::errors::*; pub fn generate_access_key() -> String { let key = thread_rng() .sample_iter(&distributions::Alphanumeric) .take(128) .map(char::from) .collect(); key } pub fn generate_keypair() -> Result<Rsa<Private>...
true
00723ea8aeb9efa44366ad0cfbbe69c3aee7fffd
Rust
gnoliyil/fuchsia
/third_party/rust_crates/vendor/aes-0.7.5/src/armv8/expand.rs
UTF-8
2,473
2.921875
3
[ "BSD-2-Clause", "Apache-2.0", "MIT", "LicenseRef-scancode-warranty-disclaimer" ]
permissive
//! AES key expansion support. use core::{arch::aarch64::*, convert::TryInto, mem, slice}; /// There are 4 AES words in a block. const BLOCK_WORDS: usize = 4; /// The AES (nee Rijndael) notion of a word is always 32-bits, or 4-bytes. const WORD_SIZE: usize = 4; /// AES round constants. const ROUND_CONSTS: [u32; 10]...
true
1863974e7b01b2275b5fe28597013f0641ecfd87
Rust
0x5c/crossterm-events-tester
/src/main.rs
UTF-8
3,279
2.875
3
[]
no_license
use std::time::Duration; use crossterm::{ event, terminal::{ enable_raw_mode, disable_raw_mode, }, style::Stylize, tty::IsTty, }; const CTRL_C: event::Event = event::Event::Key(event::KeyEvent{code: event::KeyCode::Char('c'), modifiers: event::KeyModifiers::CONTROL}); fn main() {...
true
5a50fde26661280882629d4840576818225f60c7
Rust
kkevlar/rust-morse
/morse_utils/src/lib.rs
UTF-8
11,106
2.75
3
[]
no_license
#![no_std] macro_rules! hashmap { ($( $key: expr => $val: expr ),*) => {{ let mut map = heapless::FnvIndexMap::new(); $( map.insert($key, $val); )* map }} } #[derive(PartialEq, Eq, Copy, Clone, Debug)] pub enum Morse { Dot, Dash, Error, TinySpace, LetterSpace, ...
true
1fd3124c2754534c454c97eac8b26e69748c4689
Rust
ericmcbride/primarch
/src/utils.rs
UTF-8
3,353
3.125
3
[ "MIT" ]
permissive
use clap::ArgMatches; use http; use reqwest::{Url, UrlError}; use std::io::{Error, ErrorKind, Read}; use std::fs::File; // Convert rps from string to u64. Return result enum fn parse_u64(value: &str) -> Result<u64, Box<::std::error::Error>> { let val: u64 = value.parse()?; Ok(val) } pub fn str_to_string(inpu...
true
85be617a954ea9f6d81b01695e7f7c3d690308a9
Rust
jjyr/godwoken
/gwos/crates/types/src/offchain/compatible_finalized_timepoint.rs
UTF-8
2,292
2.921875
3
[ "MIT" ]
permissive
use crate::core::Timepoint; use crate::packed::GlobalState; use crate::prelude::*; // Even after Godwoken has upgraded to v2, there are still some entities with // number-based timepoint on L1. This warpper structure includes number-based and // timestamp-based finalized timepoints, so it can be used to check finality...
true
700c9027f22b1cb8c947cedcafdd3c93cf3b838a
Rust
xlambein/rust-against-humanity
/back/src/util.rs
UTF-8
826
3.4375
3
[ "MIT" ]
permissive
pub fn expand_underscores(src: &str, length: usize) -> String { assert!(length > 0); if length == 1 { return src.to_owned(); } src.chars() .map(|c| { if c == '_' { "_".repeat(length) } else { c.to_string() } }) .collect::<Vec<_>>() .concat() } #[cfg(test)] mod tests { use super::*; ...
true
de0fa3e3ecb96e15e78fd22bc0ac7087dc3f0f31
Rust
JustAPerson/denuocc
/src/front/c/tu.rs
UTF-8
3,415
2.890625
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
// 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 http://opensource.org/licenses/MIT>, at your option. This file may not be // copied, modified, or distributed except according to those terms. //! Tra...
true
a9e0a489a49c38a99dceaea5d45966780e735d06
Rust
ndtho8205/programming-problems
/codechef/001_dsa_learning_series/week_2/pshot/src/main.rs
UTF-8
3,403
3.375
3
[ "MIT" ]
permissive
use std::fmt::Debug; use std::io::{self, BufRead}; use std::str::FromStr; fn try_read<T: BufRead>(reader: &mut T) -> String { let mut buffer = String::new(); reader .read_line(&mut buffer) .expect("error: Failed to read input from stdin"); buffer.trim().to_string() } fn read<T: FromStr, U...
true
43bdd880ca82846f7b047aa38047d6311e371e04
Rust
Kixiron/codespan-salsa
/src/main.rs
UTF-8
6,317
2.90625
3
[ "Unlicense" ]
permissive
extern crate codespan_reporting; // Tested with codespan_reporting v0.9.5 extern crate salsa; // Tested with salsa v0.15.1 use codespan_reporting::{ diagnostic::{Diagnostic, Label, LabelStyle}, files::Files, term::{ self, termcolor::{ColorChoice, StandardStream}, Config, }, }; u...
true
952ea89fe7b704e2bdabc557c74e0e9ad19034ad
Rust
d-z-h/rust-guide
/examples/text/string-parsing/src/main.rs
UTF-8
87
2.5625
3
[ "MIT", "Apache-2.0" ]
permissive
fn main() { println!("《Rust 实践指南》- 文本处理 - 字符串解析"); }
true
857e5732caae21b4c3d782417579550e68e6ce4f
Rust
vgene/bencher_scrape
/crates/crates/bucket_queue/src/index/simple/mod.rs
UTF-8
2,886
3.21875
3
[]
no_license
use super::*; use std::cmp; pub struct SimpleIndex { len: usize, min: Option<usize>, max: Option<usize>, } impl Index for SimpleIndex { fn new() -> Self { Self { len: 0, min: None, max: None } } fn add<B: Bucket>(&mut self, priority: usize, buckets: &Vec<Option<B>>) { self.ad...
true
7c8c52884b09a2cded823556162fc805e80070d0
Rust
imbolc/rust-derive-macro-guide
/src/lib.rs
UTF-8
298
3.09375
3
[]
no_license
use mytrait_derive::MyTrait; trait MyTrait { fn answer() -> i32 { 42 } } #[derive(MyTrait)] struct Foo; #[derive(MyTrait)] #[my_trait(answer = 0)] struct Bar; #[test] fn default() { assert_eq!(Foo::answer(), 42); } #[test] fn getter() { assert_eq!(Bar::answer(), 0); }
true
8b154569496003e43e2b0ea02c77c66450cf02d0
Rust
miged/project-euler
/rust/p3.rs
UTF-8
352
2.953125
3
[]
no_license
/* Problem 3 The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 600851475143 ? */ fn main() { let mut num: i64 = 600851475143; let mut highest = 1; while num > 1 { highest += 1; while num % highest == 0 { num /= highest; } ...
true
49aaea84b34fed9712b57a3f8eb4d874ef64678e
Rust
NoelWidmer/cracking_the_coding_interview
/src/solutions/chapter1/s6.rs
UTF-8
2,077
3.75
4
[ "MIT" ]
permissive
fn compress(input: &str) -> String { let mut output = String::new(); let mut last_char = None; let mut count = 0; for c in input.chars() { match last_char { Some(last_char_) => { if c == last_char_ { count += 1; } else { ...
true
f8797273f7001b841920ffdaddc193a2accd0875
Rust
couchand/tracing-span-tree
/tests/it.rs
UTF-8
631
2.578125
3
[ "MIT", "Apache-2.0" ]
permissive
use std::{thread, time::Duration}; #[test] fn not_aggregated() { tracing_span_tree::span_tree().enable(); top_level() } #[test] fn aggregated() { tracing_span_tree::span_tree().aggregate(true).enable(); top_level() } fn top_level() { let _s = tracing::info_span!("top_level").entered(); for i ...
true
0ef264a66dc886be7e0308795b18fa935940f83d
Rust
steadylearner/Rust-Full-Stack
/yew/router/src/routing.rs
UTF-8
3,447
3.40625
3
[ "MIT" ]
permissive
//! Service to handle routing. use stdweb::web::History; use stdweb::web::Location; use stdweb::web::window; use stdweb::Value; use stdweb::web::EventListenerHandle; use stdweb::web::event::PopStateEvent; use stdweb::web::IEventTarget; use stdweb::JsSerialize; use stdweb::unstable::TryFrom; use yew::callback::Callback...
true
ce7937a899e9839432a22401612682a3d0bfe229
Rust
rgamba/evento
/demo/src/lib.rs
UTF-8
4,347
2.703125
3
[]
no_license
use actix_web::rt::blocking::run; use anyhow::{format_err, Result}; use chrono::Utc; use evento::{ parse_input, run, wait, Operation, OperationInput, WaitParams, Workflow, WorkflowError, WorkflowStatus, }; use evento_derive::workflow; use log; use reqwest; use serde::{Deserialize, Serialize}; use std::collectio...
true
b4f7e3cd185fa90cf0514b48b6af307e44e15d1b
Rust
EFanZh/LeetCode
/src/problem_0611_valid_triangle_number/sort_then_binary_search.rs
UTF-8
1,140
3.078125
3
[]
no_license
pub struct Solution; // ------------------------------------------------------ snip ------------------------------------------------------ // impl Solution { pub fn triangle_number(nums: Vec<i32>) -> i32 { let mut result = 0; let mut nums = nums; nums.sort_unstable(); for (i, fir...
true
b378c6b71d6df971e317dbe337a7ac7d3a28051a
Rust
ojii/aoc2019
/src/day10.rs
UTF-8
6,721
2.984375
3
[]
no_license
use crate::render::render; use itertools::Itertools; use std::collections::{HashMap, VecDeque}; use std::f64::consts::TAU; #[derive(Debug, Clone, Eq, PartialEq, Hash)] struct Asteroid { x: i32, y: i32, } impl Asteroid { fn calculate_visible(&self, universe: &[Asteroid]) -> usize { universe ...
true
15c4b08132620c581fe50e42ef0ec4af84d9290f
Rust
longde123/clr-profiler
/clr_profiler/src/cil/method_header.rs
UTF-8
3,639
2.875
3
[ "Apache-2.0", "MIT" ]
permissive
#![allow(non_upper_case_globals)] use crate::cil::{check_flag, il_u32, Error}; bitflags! { pub struct MethodHeaderFlags: u8 { const CorILMethod_FatFormat = 0x3; const CorILMethod_TinyFormat = 0x2; const CorILMethod_MoreSects = 0x8; const CorILMethod_InitLocals = 0x10; } } #[deri...
true
eb70bdf4b0c0902b2f9e3d05837bb71f7da8557a
Rust
reactive-systems/REHyper
/hyperltl/src/parser.rs
UTF-8
13,337
3.15625
3
[ "MIT" ]
permissive
use std::error::Error; use super::*; pub type Result<T> = std::result::Result<T, ParserError>; #[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] pub enum Token { EOF, Id(String), True, False, Forall, Exists, LParen, RParen, Underscore, Dot, And, Hat, Or, Not, Impl, Equiv, Next, Un...
true
1b4e662c40c9075f717cdcf8d1edd936ba18d0c1
Rust
gkorpal/sidh-rs
/src/sidh.rs
UTF-8
46,943
2.625
3
[ "BSD-3-Clause", "MIT", "LicenseRef-scancode-warranty-disclaimer", "LicenseRef-scancode-unknown-license-reference" ]
permissive
// This file is part of sidh-rs. // Copyright (c) 2017 Erkan Tairi // See LICENSE for licensing information. // // Author: // - Erkan Tairi <erkan.tairi@gmail.com> // //! Implemention of (ephemeral) supersingular isogeny Diffie-Hellman. //! //! This package follows the usual naming convention, writing "Alice" for the ...
true
76dc644f798edba50389761f71b20b77dcf28fc8
Rust
vkill/books-rs
/book/src/ch15/sec08.rs
UTF-8
3,888
4.0625
4
[]
no_license
//! [Preventing Reference Cycles]: Turning an `Rc<T>` into a `Weak<T>` //! //! [preventing reference cycles]: https://doc.rust-lang.org/book/ch15-06-reference-cycles.html#preventing-reference-cycles-turning-an-rct-into-a-weakt //! //! # Examples //! //! ```rust //! use std::error::Error; //! use std::rc::Rc; //! //! us...
true
753747a34862d6c14bd32acc6b1c32f7a8bcfa64
Rust
debris/matrix-rocketchat
/src/matrix-rocketchat/handlers/error_notifier.rs
UTF-8
1,686
2.78125
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
use diesel::sqlite::SqliteConnection; use ruma_identifiers::{RoomId, UserId}; use slog::Logger; use i18n::*; use api::MatrixApi; use db::User; use config::Config; use errors::*; /// Notifies the user about errors pub struct ErrorNotifier<'a> { /// Application service configuration pub config: &'a Config, ...
true
09fb83ba95736b7e7dd4faacff1dd371dbfc3ec6
Rust
vitocchi/yew-mandelbrot
/src/main.rs
UTF-8
2,864
2.875
3
[]
no_license
mod mandelbrot; use wasm_bindgen::JsCast; use yew::events::ChangeData; use yew::prelude::{html, Component, ComponentLink, Html, NodeRef, ShouldRender}; use yew::services::ConsoleService; use yew::web_sys::{CanvasRenderingContext2d, HtmlCanvasElement}; struct App { link: ComponentLink<Self>, canvas_ref: NodeRef...
true
550807b466bc8269d2e22e7a1793d548be185464
Rust
starblue/advent_of_code
/a2020/src/bin/a202013.rs
UTF-8
3,496
2.78125
3
[]
no_license
use core::mem::swap; use std::io; use std::io::Read; use std::str::FromStr; use nom::branch::alt; use nom::bytes::complete::tag; use nom::character::complete::digit1; use nom::character::complete::line_ending; use nom::combinator::map_res; use nom::combinator::value; use nom::multi::separated_list1; use nom::IResult;...
true
0b229e9bf2c1638f195e59a6d071fd40ac897ae7
Rust
fabianschuiki/moore
/src/circt/src/moore.rs
UTF-8
2,668
2.890625
3
[ "Apache-2.0", "MIT" ]
permissive
// Copyright (c) 2016-2021 Fabian Schuiki use crate::crate_prelude::*; /// Define a shift operation with value and amount operands and a /// unit attribute indicating whether the shift is arithmetic. macro_rules! def_shift_operation { ($name:ident, $operation_name:expr) => { def_operation_single_result!($...
true
15e4bc0559a990a56ba083e9fca0ffd114da97dc
Rust
harryaskham/scrabrudo
/src/dict.rs
UTF-8
2,230
2.90625
3
[]
no_license
use sstable::{Options, SSIterator, Table}; use std::collections::HashMap; use std::collections::HashSet; use std::fs::File; use std::io::{BufRead, BufReader}; use std::path::Path; use std::sync::Mutex; type Dictionary = HashSet<String>; lazy_static! { static ref DICT: Mutex<Option<Dictionary>> = Mutex::new(None);...
true
d1a2613c8fe5a6e397b9d0944f4be629d4b0aeab
Rust
buckn/quad-snd
/src/web_snd.rs
UTF-8
1,813
2.78125
3
[]
no_license
use crate::PlaySoundParams; extern "C" { fn audio_init(); fn audio_add_buffer(content: *const u8, content_len: u32) -> u32; fn audio_play_buffer(buffer: u32, volume_l: f32, volume_r: f32, speed: f32, repeat: bool); fn audio_source_is_loaded(buffer: u32) -> bool; fn audio_source_set_volume(buffer: u...
true