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
a61373ac1df4cf5bdbd30c2ba46e7c97503a759b
Rust
Mvdboon/ScalingUpStayingSecure
/Model/src/util/errors.rs
UTF-8
2,389
2.609375
3
[ "MIT" ]
permissive
use std::io::Error as ioError; use statrs::StatsError; use thiserror::Error; use tokio::task::JoinError; /// Errors that can derive from the Util module. #[derive(Error, Debug)] pub enum UtilError { #[error(transparent)] StatsError { #[from] source: StatsError, }, #[error(transparent)...
true
b31827a4ec60f3f019432c3deeb7807d5d41b9c2
Rust
repnop/cargo-localreg
/src/rest.rs
UTF-8
2,899
2.703125
3
[]
no_license
use std::{ fs::OpenOptions, io::{BufRead, BufReader, Read, Write}, path::PathBuf, }; use tokio::{fs::File, prelude::Future}; use tower_web::*; struct RestServer; impl_web! { impl RestServer { #[get("/root")] #[content_type("plain")] fn root(&self) -> impl Future<Item = File, Er...
true
98ed3da68916344f220cc104daf39ed1777087f4
Rust
maidsafe/safe_network
/sn_transfers/src/wallet/keys.rs
UTF-8
3,628
2.59375
3
[]
no_license
// Copyright 2023 MaidSafe.net limited. // // This SAFE Network Software is licensed to you under The General Public License (GPL), version 3. // Unless required by applicable law or agreed to in writing, the SAFE Network Software distributed // under the GPL Licence is distributed on an "AS IS" BASIS, WITHOUT WARRANTI...
true
477bc295355fa592f940d5c4f18428b62a1cbbfc
Rust
Liby99/mpm-rs
/examples/examples/multi_balls.rs
UTF-8
1,532
2.65625
3
[]
no_license
use mpm_rs::*; use mpm_examples::*; use mpm_viewer::*; use nalgebra as na; struct Ball { center: Vector3f, velocity: Vector3f, radius: f32, mass: f32, color: Color, } fn main() { run_example( Config { world_dt: 0.001, output_directory: "result/bunny", num_cycles: 5000, dump_ski...
true
d45e888d3d45b70707e33c096d7d3271e0e26aa4
Rust
redox-os/periodictable
/src/widgets/atom_widget.rs
UTF-8
4,540
2.640625
3
[ "MIT" ]
permissive
use std::cell::{Cell, RefCell}; use std::sync::Arc; use natural_constants::chemistry::AtomInfo; use orbclient::Renderer; use orbtk::event::Event; use orbtk::point::Point; use orbtk::rect::Rect; use orbtk::theme::Theme; use orbtk::thickness::Thickness; use orbtk::traits::{Click, Place}; use orbtk::widgets::{HorizontalP...
true
d8c1f5fcd1be5d48997e026760a3cc931287f027
Rust
lvdr/aoc2018
/day_09/src/main.rs
UTF-8
1,637
3.28125
3
[ "BSD-2-Clause" ]
permissive
use std::collections::VecDeque; #[cfg(test)] mod tests { use super::*; #[test] fn test_all() { assert_eq!(high_score(9, 25), 32); assert_eq!(high_score(10, 1618), 8317); assert_eq!(high_score(13, 7999), 146373); assert_eq!(high_score(17, 1104), 2764); assert_eq!(hig...
true
8822ac7967c308ae13bdbb7d8c9f53d2cc6ea527
Rust
morganfogg/zanthe
/src/game/instruction/result.rs
UTF-8
405
3.03125
3
[ "MIT" ]
permissive
/// The result of an instruction pub enum Result { /// Continue executing the current routine. Continue, /// Return from the current routine with the given value. Return(u16), /// Quit the game. Quit, /// Restart the game. Restart, /// Call a new routine. Invoke { address...
true
6fee5022f7bbff2437e95d13b04cc75c1cf6b316
Rust
audacioustux/exercism_rs
/proverb/src/lib.rs
UTF-8
535
3.109375
3
[]
no_license
pub fn build_proverb(items: &[&str]) -> String { let mut proverb = Vec::with_capacity(items.len()); let mut items_iter = items.iter().peekable(); while let Some(want_word) = items_iter.next() { if let Some(lost_word) = items_iter.peek() { proverb.push(format!( "For want...
true
77a169086720b4b660099b7220813326b9fccfad
Rust
valarauca/dice_backend
/dice_backend/src/cfgbuilder/expression.rs
UTF-8
2,265
2.984375
3
[]
no_license
use std::hash::{Hash, Hasher}; use super::super::parser_output::{ Expression, FunctionInvocation, GetType, Literal, Operation, TypeData, }; use super::super::seahash::SeaHasher; use super::identifier::Identifier; /// HashedExpressions are built ontop of BlockExpressions. /// They're goal is to start linking toge...
true
d61b4097d6ac94dd5e3a8ea731fb6aabb35027c1
Rust
GabrielMajeri/rspirv
/rspirv/sr/context.rs
UTF-8
12,423
2.5625
3
[ "Apache-2.0" ]
permissive
// Copyright 2017 Google Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in...
true
732fddcc8792f87ec1f89de53538e1894abe75f6
Rust
SuperCleanMe/RSV
/src/parser.rs
UTF-8
3,235
3.0625
3
[ "MIT" ]
permissive
use crate::structs::{Content, Entry}; use crate::tokenizer::{Token, Tokens}; pub fn parse(tree: Vec<Token>, has_headers: bool) -> Content { let mut line = String::new(); let mut body: String = String::new(); let mut previous: Option<Token> = None; let mut in_head = true; let mut in_quote = false; ...
true
b42db5c4e8a51569c64ad1c3054d271c3bea19cc
Rust
tylerhawkes/adventofcode2018
/src/day12-wish.rs
UTF-8
6,421
3.15625
3
[]
no_license
use std::fmt::Debug; use std::fmt::Formatter; use std::fmt::Error; use std::fmt::Display; pub fn compute(input: &[String]) { let left_5: u64 = 0x1f << 59; println!("{:x}", left_5); let mut iter = input.iter(); let initial_state = (&iter.next().unwrap().clone()[15..]).to_owned(); let initial_state: Vec<bool> ...
true
fa2d2d65cfb34636eba4e887c95f28f9f4721e0e
Rust
jduimovich/rustgc
/src/main.rs
UTF-8
3,716
2.8125
3
[]
no_license
mod gc; mod rnd; use std::io::stdout; use std::io::Write; use std::env; const LOOP: usize = 500000; const MAX_OBJECT_SIZE: usize = 32; const NUMBER_OF_ROOTS: usize = 8; fn main() { let args: Vec<String> = env::args().collect(); let mut mem = gc::Memory::initialze_memory(); println!( "New Heap Size {}", mem.e...
true
46701d558ada4352a255e53e13bf5bbc73e1969f
Rust
oxidecomputer/third-party-api-clients
/sendgrid/src/traits.rs
UTF-8
2,860
2.625
3
[ "MIT" ]
permissive
#![allow(clippy::field_reassign_with_default)] use crate::ClientError; use crate::{ClientResult, Response}; #[async_trait::async_trait] pub trait MailOps { /// Send a plain text email. /// /// This is a nicer experience than using `post`. async fn send_plain_text( &self, subject: &str, ...
true
cfb6ad2159f152a8ca3f8a833a6df1af4ebe497b
Rust
MarimeGui/standard_midi_file
/src/track/event.rs
UTF-8
18,970
2.84375
3
[]
no_license
use crate::error::SMFError; use crate::vlv::VLV; use crate::Result; use ez_io::{ReadE, WriteE}; use std::io::{Read, Seek, SeekFrom, Write}; /// An Event in a TrackEvent inside a Track of a MIDI File. /// This particular implementation puts all the MIDI, SysEx and Meta Events in a single place for convenience. #[derive...
true
cf2058e069215ff99a7ea3caf053986e1e4e7c44
Rust
asuivelentine/dedup
/src/config.rs
UTF-8
1,257
3.203125
3
[]
no_license
use std::ffi::OsString; use std::path::Path; #[derive(Debug, Clone)] pub struct Config { path: OsString, ignore_empty: bool, ignore_link: bool, } impl Config { pub fn new<S: Into<String>>(dir: S) -> Config { Config { path: OsString::from(dir.into()), ignore_empty: fals...
true
ef0aeb20511ea6ede6d8ae7b8d12051bfdf68aa2
Rust
Bathtor/weld
/tests/common/mod.rs
UTF-8
4,444
2.875
3
[ "BSD-3-Clause" ]
permissive
//! Utilities and helper functions for integration tests. #![allow(dead_code)] extern crate libc; extern crate weld; use weld::common::WeldRuntimeErrno; use weld::*; use std::convert::AsRef; use self::libc::{c_char, c_void}; use std::ffi::{CStr, CString}; #[derive(Clone, Debug)] #[repr(C)] pub struct WeldVec<T> { ...
true
5faa790fee3f1afe1dbf2abff0b59a0b91d25b35
Rust
awelkie/rustfst
/rustfst/src/algorithms/cache/fst_impl.rs
UTF-8
3,263
2.828125
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use std::collections::{HashSet, VecDeque}; use std::fmt::Debug; use std::slice::Iter as IterSlice; use anyhow::Result; use crate::algorithms::cache::CacheImpl; use crate::fst_traits::{ExpandedFst, Fst, MutableFst}; use crate::semirings::Semiring; use crate::{Arc, StateId}; pub trait FstImpl: Debug { type W: Semi...
true
6b8d24b3efb622d3a3f985344bf6fabdf090f41c
Rust
RNAcentral/rnacentral-import-pipeline
/utils/rnc-test-utils/src/lib.rs
UTF-8
1,654
3.453125
3
[ "GPL-1.0-or-later", "Apache-2.0", "Artistic-1.0-Perl", "LicenseRef-scancode-other-copyleft", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use std::{ error::Error, io, io::{ BufRead, Write, }, process::Output, }; use tempfile::NamedTempFile; /// This is a trait to extract the JSON encoded lines of something and produce a vector of /// all JSON values parsed. pub trait Jsonl { /// Parse and create a vector of each ...
true
bef32674bd8dc7d86cb2f0a951a183a48d2cb879
Rust
occlum/occlum
/tools/copy_bom/src/bom.rs
UTF-8
30,568
2.703125
3
[ "BSD-3-Clause" ]
permissive
//! This file defines data structures to store contents in bom file //! as well as all management on these structures. //! Structures `Bom`, `Target`, `SymLink`, `Source`, `NormalFile`, `FileWithOption` //! are used to parse the bom file. //! Structures ending with `management` are used to define managements on differe...
true
35e9e44e624d213d6d535e1382d1625fa40258c4
Rust
puppyofkosh/safer-c-compiler
/src/type_checker.rs
UTF-8
18,254
2.71875
3
[]
no_license
use ast::AstExpressionNode; use ast::Block; use ast::PointerType; use ast::Expression; use ast::FunctionType; use ast::FunctionCall; use ast::Program; use ast::Statement; use ast::VarType::*; use ast::VarType; use ast::StructDefinition; use ast; use ast_helper::is_pointer; use code_block::CodeBlock; use type_checker...
true
c2089954b11c8314ad06c92682a6fe741c6db559
Rust
Radviger/rhai
/tests/ops.rs
UTF-8
608
3.25
3
[]
no_license
extern crate rhai; use rhai::Engine; #[test] fn test_ops() { let mut engine = Engine::new(); if let Ok(result) = engine.eval::<i64>("60 + 5") { assert_eq!(result, 65); } else { assert!(false); } if let Ok(result) = engine.eval::<i64>("(1 + 2) * (6 - 4) / 2") { assert_eq!(...
true
ecd154477ac337682c84c7e45bba65231780d2bb
Rust
IThawk/rust-project
/rust-master/src/test/run-pass/self/arbitrary_self_types_trait.rs
UTF-8
364
2.921875
3
[ "MIT", "LicenseRef-scancode-other-permissive", "Apache-2.0", "BSD-3-Clause", "BSD-2-Clause", "NCSA" ]
permissive
// run-pass #![feature(arbitrary_self_types)] use std::rc::Rc; trait Trait { fn trait_method<'a>(self: &'a Box<Rc<Self>>) -> &'a [i32]; } impl Trait for Vec<i32> { fn trait_method<'a>(self: &'a Box<Rc<Self>>) -> &'a [i32] { &***self } } fn main() { let v = vec![1,2,3]; assert_eq!(&[1,2,...
true
d32a7e75eaf3e14f134d30696943127215cc9918
Rust
ischeinkman/fakefat
/src/changeset.rs
UTF-8
7,444
2.734375
3
[ "MIT" ]
permissive
#![allow(unused)] use crate::fat::FatEntryValue; #[cfg(feature = "alloc")] pub type ChangeSet = alloc_changeset::AllocChangeSet; #[cfg(feature = "alloc")] pub type ChangeBuff = alloc_changeset::AllocChangeBuff; #[cfg(feature = "alloc")] mod alloc_changeset { use super::*; #[cfg(feature = "std")] use std:...
true
ab26e2a6089d8e6f38d4dc17b99cca6cb5605352
Rust
manoet/siwir
/src/basic_parser.rs
UTF-8
5,800
2.9375
3
[ "MIT" ]
permissive
// Copyright (c) 2019 Marco Giglio // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, ...
true
c66e446915d14e09c3a7517accf9b053e26c0b9b
Rust
cassaundra/col
/src/test.rs
UTF-8
1,623
3.40625
3
[ "MIT" ]
permissive
use std::io::Read; use crate::interpreter::Interpreter; use crate::program::SimpleProgramState; fn get_output_with_input<R: Read>(source: &str, reader: &mut R) -> String { let mut output = Vec::new(); Interpreter::<SimpleProgramState>::new(source, Some(reader), Some(&mut output)) .run() .unwrap(); return Strin...
true
1a0e7293721e93d7395979ccc676f144c339dc88
Rust
nlevitt/monie
/src/lib.rs
UTF-8
11,516
2.953125
3
[ "MIT" ]
permissive
//! Monie-in-the-middle http(s) proxy library //! //! Observe and manipulate requests by implementing `monie::Mitm`. //! //! Here is a skeleton to help get started: //! //! ``` //! use futures::future::Future; //! use hyper::{Body, Chunk, Request, Response, Server}; //! use monie::{Mitm, MitmProxyService}; //! //! stru...
true
a31c82dd1aeb9ea4440b128c21f4451848f59c94
Rust
leftwm/leftwm
/leftwm/src/bin/leftwm-state.rs
UTF-8
6,742
2.515625
3
[ "MIT" ]
permissive
use clap::{arg, command}; use leftwm_core::errors::{LeftError, Result}; use leftwm_core::models::dto::{DisplayState, ManagerState}; use liquid::Template; use std::ffi::OsStr; use std::path::Path; use std::str; use tokio::fs; use tokio::io::{AsyncBufReadExt, BufReader, Lines}; use tokio::net::UnixStream; use xdg::BaseDi...
true
68944b850fa4b14f470ceb6fbe01adf5a4cea41a
Rust
creinig/naday
/src/report/sliding.rs
UTF-8
4,682
3.171875
3
[ "MIT" ]
permissive
use crate::model::{Activity, CategoryLookup, Config}; use crate::report::common::DayStats; use crate::storage; use chrono::{Date, Datelike, Duration, Local}; use std::collections::HashMap; use std::vec::Vec; pub fn sliding_days( end_date: Date<Local>, number_of_days: u32, category: Option<String>, conf...
true
77c5e1a83b3f688a5b6582cd9132e43018854c14
Rust
tedle/Advent-of-Code-2019
/12/src/main.rs
UTF-8
3,894
3
3
[]
no_license
use std::collections::HashSet; #[derive(Clone, Copy, Debug, Hash, PartialEq, Eq)] struct Vec3 { x: i64, y: i64, z: i64, } impl Vec3 { fn new() -> Vec3 { Vec3 { x: 0, y: 0, z: 0 } } } #[derive(Clone, Copy, Debug, Hash, PartialEq, Eq)] struct Moon { pos: Vec3, velocity: Vec3, } imp...
true
e548132b6d9e53a3d944e488ef0ecc1f7709dccd
Rust
ahbali/adventofcode2020
/day11/src/main_1.rs
UTF-8
2,704
3.09375
3
[ "MIT" ]
permissive
use std::error::Error; use std::io::{self, prelude::*}; use std::{vec, writeln}; #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] enum Cell { Empty, Occupied, Floor, } fn neighbor_cells(i: usize, j: usize, board: &Vec<Vec<Cell>>) -> Vec<&Cell> { let l_len = board[0].len() as isize; le...
true
6dfc5249affa80e6059445f06fa7787e44b6b17e
Rust
chongyi/inspirer-rs
/inspirer-content/src/model/paginate.rs
UTF-8
875
3.140625
3
[ "MIT" ]
permissive
use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Copy, Deserialize, Serialize, PartialEq)] #[serde(default)] pub struct Pagination { pub page: usize, pub page_size: usize, } impl Default for Pagination { fn default() -> Self { Pagination { page: 1, page_size: 20,...
true
7b9c2137cc2d1fe8469e578790756b1e3c8ec4fd
Rust
farodin91/rust-analyzer
/crates/ra_analysis/src/descriptors/mod.rs
UTF-8
1,802
2.625
3
[ "MIT", "Apache-2.0" ]
permissive
pub(crate) mod module; use ra_syntax::{ ast::{self, AstNode, NameOwner}, }; #[derive(Debug, Clone)] pub struct FnDescriptor { pub name: String, pub label: String, pub ret_type: Option<String>, pub params: Vec<String>, } impl FnDescriptor { pub fn new(node: ast::FnDef) -> Option<Self> { ...
true
044d8de886a329debf34865fcfb511a0f243825b
Rust
muffix/exercism-rust
/luhn-from/src/lib.rs
UTF-8
1,837
3.625
4
[]
no_license
pub struct Luhn { digits: Option<Vec<u32>>, } impl Luhn { pub fn is_valid(&self) -> bool { if self.digits.is_none() { return false; } self.digits .clone() .unwrap() .iter() .enumerate() .map(|(i, d)| { ...
true
1ff27475e62a489d7a89c3f36a0d469d2d088173
Rust
boybird/leetcode-rust
/src/array/l0011_盛最多水的容器.rs
UTF-8
1,221
2.875
3
[]
no_license
/* * @lc app=leetcode.cn id=11 lang=rust * * [11] 盛最多水的容器 */ struct Solution; // @lc code=start impl Solution { pub fn max_area(height: Vec<i32>) -> i32 { let len = height.len(); if len <= 1 { return 0; }; let mut i: usize = 0; let mut j = len - 1; let...
true
d44c06849e45be9d2a6484b3b678eb49cfcd4b5f
Rust
arapat/sparrow
/src/config.rs
UTF-8
4,345
2.78125
3
[]
no_license
use commons::io::create_bufreader; /// Configuration for training and testing with Sparrow #[derive(Clone, Serialize, Deserialize)] pub struct Config { /// File path to the training data pub training_filename: String, /// Number of training examples pub num_examples: usize, /// Number of features ...
true
6a46e813794cf4c18ffe861b120535343f6bdde9
Rust
axelf4/dumle
/src/lib.rs
UTF-8
34,085
3.1875
3
[]
no_license
//! Virtual DOM library. //! //! The [html] macro is used for rendering virtual trees. //! The real DOM can then be patched to match a virtual tree with [Context::patch]. //! //! ## Example //! //! The following example creates a simple counter that can be incremented: //! //! ```no_run //! use dumle::{hook::UseState, ...
true
a062426ec43ddd561950c1f85b4a5df3ef8b9c6e
Rust
pocesar/actor-rust-scraper
/src/extractor.rs
UTF-8
7,706
2.625
3
[ "LicenseRef-scancode-warranty-disclaimer" ]
no_license
use crate::input::Extract; use crate::requestlist::RequestList; use crate::scraper::{ Html, Selector }; use crate::serde_json::Value; use futures::{ future::Future, stream::{ Stream, StreamExt, futures_unordered::FuturesUnordered } }; use std::{ collections::{ HashMap }, time...
true
68f42513129b6322f50a4658e7f52b0ef82a6270
Rust
toybox-rs/toybox-rs
/tb_gridworld/src/types.rs
UTF-8
1,480
2.9375
3
[]
no_license
use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use std::collections::HashMap; use toybox_core::graphics::Color; #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)] pub struct TileConfig { /// What reward (if any) is given or taken by passing this tile? pub reward: i32, /// Is this t...
true
d53b5fbe2255d6105f14b72f11a025f42f671b2a
Rust
NilPointer-Software/open-source-link-shortener
/src/main.rs
UTF-8
3,732
2.703125
3
[]
no_license
#![feature(proc_macro_hygiene, decl_macro)] mod database; mod models; pub mod schema; mod host_guard; #[macro_use] extern crate rocket; #[macro_use] extern crate rocket_contrib; #[macro_use] extern crate diesel; use rocket_contrib::templates::Template; use crate::database::{MainDbConn}; use rocket::request::Form; us...
true
42c75c534bfef746c057f2dbcf84e68c70807bdf
Rust
saleemrashid/ocr_latin_vocabulary-rs
/src/main.rs
UTF-8
1,741
2.765625
3
[ "Apache-2.0", "MIT" ]
permissive
extern crate csv; extern crate unicode_normalization; use csv::Reader; use std::io; use unicode_normalization::UnicodeNormalization; const REQUIRED_COLUMN_COUNT: usize = 4; fn main() { let mut reader = Reader::from_reader(io::stdin()).has_headers(false); let records = reader.byte_records() .map(Resu...
true
7fbe50e967a9bc1035a329d1bd4ff0fd5c9ce882
Rust
paulcavallaro/hindley-milner
/src/parsing/parser.rs
UTF-8
4,355
3.203125
3
[]
no_license
use std::path::{Path}; use std::io::{Read, Result}; use std::fs::{File}; use std::rc::Rc; use parsing::ast::{Token}; use utils::interner::{StrInterner, Name}; pub fn lex_file(path : &Path) -> Result<Lexer> { let file = try!(File::open(path)); let lexer = try!(Lexer::new(file)); Ok(lexer) } struct Lexer { pub ...
true
7b00f73a8247941de9bb1eef435e580f7e6116a1
Rust
kevincharm/ykk
/src/parser/local_file_header.rs
UTF-8
2,335
2.890625
3
[]
no_license
use byteorder::{LittleEndian, ReadBytesExt}; use std::io::Cursor; use std::str; #[allow(dead_code)] pub struct LocalFileHeader { pub version: u16, pub flags: u16, pub compression: u16, pub modified_time: u16, pub modified_date: u16, pub crc32: u32, pub compressed_size: u32, pub uncompre...
true
433078928dcdf6f6079d94255d4d58b0f3e9f807
Rust
mateuszJS/battle
/crate/src/weapon_types.rs
UTF-8
2,812
3.078125
3
[ "MIT" ]
permissive
pub enum WeaponType { StandardRifle, LaserRifle, Grenade, HitTheGround, } pub struct Weapon { pub name: WeaponType, pub chances_to_reload: f32, pub reload_time: u16, pub shoot_time: u16, pub scatter: f32, pub bullets_speed: f32, pub damage: f32, pub representation_id: f32, pub explosion_range...
true
44da4e257cd3046a8f90d60bde53b36fe843bcb8
Rust
rubenjr0/mips
/src/cpu.rs
UTF-8
3,065
3.140625
3
[]
no_license
use crate::bus::Bus; pub struct Cpu { pc: u32, regs: [u32; 32], rom: Vec<u8>, bus: Bus, } impl Cpu { pub fn new(rom: Vec<u8>) -> Cpu { Cpu { pc: 0, regs: [0; 32], rom: rom, bus: Bus::new(), } } pub fn can_run(&self) -> bool {...
true
2585723de2b995e608490221b4164ed43ec617ed
Rust
fabianboesiger/trader-deprecated-4
/src/strategies/random.rs
UTF-8
908
2.796875
3
[]
no_license
use super::Strategy; use crate::{ exchanges::{Order, Side, Trade}, indicators::*, }; use std::fmt; #[derive(Clone)] pub struct Random { stdev: Stdev, } impl Random { pub fn new() -> Self { Self { stdev: Stdev::new(200.0), } } } impl Strategy for Random { fn run(&mu...
true
8f4279e99bc69d5298468ac081e114dfec5634e1
Rust
BurntSushi/chan-signal
/examples/select.rs
UTF-8
908
3.0625
3
[ "MIT", "Unlicense" ]
permissive
#[macro_use] extern crate chan; extern crate chan_signal; use std::thread; use std::time::Duration; use chan_signal::Signal; fn main() { // Signal gets a value when the OS sent a INT or TERM signal. let signal = chan_signal::notify(&[Signal::INT, Signal::TERM]); // When our work is complete, send a senti...
true
25b77e2cc8842ebd006549b3c6e988555969322f
Rust
eggmunkee/rust-vue-app
/src/main.rs
UTF-8
2,125
2.515625
3
[]
no_license
use actix_web::{middleware, web, App, HttpServer}; use std::sync::{Mutex}; // Register modules mod macros; mod core; mod urls; mod views; mod db; mod app_context; mod app; mod survey; use crate::app_context::{AppContext,AppInstanceContext}; #[actix_rt::main] async fn main() -> std::io::Result<()> { std::env::set...
true
8267fbcda14ac4c80c20db03568dd94fbf67cbaf
Rust
ethiclesshacker/image-ed-rust
/src/main.rs
UTF-8
1,934
3.03125
3
[]
no_license
extern crate image; use image::io::Reader as ImageReader; use image::ImageFormat; use image::{Rgba}; use imageproc::drawing::draw_text_mut; use rusttype::{Font, Scale}; use std::env; use std::fs::File; use std::io::Cursor; use std::path::Path; fn main() { let file = if env::args().count() == 2 { env::ar...
true
33944af1a2250919e3b7769c0734a7de0e708b84
Rust
phlip9/cryptopals_rs
/src/set3/p22.rs
UTF-8
1,097
2.859375
3
[ "MIT" ]
permissive
use std::time::{SystemTime, UNIX_EPOCH}; use rand::{Rng, SeedableRng, weak_rng}; use util::MT19937Rng; fn epoch_time() -> u64 { SystemTime::now() .duration_since(UNIX_EPOCH).unwrap() .as_secs() } #[test] fn run() { let mut w_rng = weak_rng(); let mut mt_rng = MT19937Rng::new_unseeded(); ...
true
8b9b6221dc0e401ab093ce32aa7bd21e66da4996
Rust
wa7sa34cx/tarantool-module
/src/fiber.rs
UTF-8
15,398
3.390625
3
[ "BSD-3-Clause", "BSD-2-Clause" ]
permissive
//! Сooperative multitasking module //! //! With the fiber module, you can: //! - create, run and manage [fibers](struct.Fiber.html), //! - use a synchronization mechanism for fibers, similar to “condition variables” and similar to operating-system //! functions such as `pthread_cond_wait()` plus `pthread_cond_signal()...
true
b7256b659de529f6c4b009ecd9d6af367c687b88
Rust
tmzt/isymtope
/isymtope-ast-common/src/expressions/path.rs
UTF-8
6,136
2.8125
3
[ "MIT" ]
permissive
use std::marker::PhantomData; use itertools::Itertools; use itertools::FoldWhile::Done; use itertools::join; use traits::*; use error::*; use super::*; #[allow(dead_code)] #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum PathComponentValue<T> { Member(String, PhantomData<T>), MethodCall(String, Option<V...
true
a76dbb64ca609e4c462c8e0835489e28b4fdfdf5
Rust
amorriscode/sorting-hat
/src/main.rs
UTF-8
1,991
2.546875
3
[]
no_license
use std::io; use termion::clear; use termion::event::Key; use termion::input::MouseTerminal; use termion::input::TermRead; use termion::raw::IntoRawMode; use termion::screen::AlternateScreen; use tui::backend::TermionBackend; use tui::layout::{Constraint, Direction, Layout}; use tui::style::{Color, Modifier, Style}; us...
true
8b41542e089f8795336e54a7e2de1e4ff345a436
Rust
raymundovr/exercism-rust
/nucleotide-count/src/lib.rs
UTF-8
861
3.375
3
[]
no_license
use std::collections::HashMap; static NUCLEOTIDES: [char; 4] = ['A', 'C', 'G', 'T']; fn is_valid(c: &char) -> bool { NUCLEOTIDES.contains(c) } pub fn count(nucleotide: char, dna: &str) -> Result<usize, char> { if !is_valid(&nucleotide) { return Err(nucleotide); } let mut count: usize = 0; ...
true
92709bf8e57b1e5e5edf11a50f9ad8005fbcb6a6
Rust
Kyle-Mendes/dailyprogrammer
/dp-206-recurssion/rust/src/main.rs
UTF-8
2,310
3.78125
4
[]
no_license
use std::io; fn main() { let inputs = get_input(); recur(get_operators(&inputs), &inputs); } //Function to get inputs from the command line. //Returns Vec<String> fn get_input() -> Vec<String> { let mut reader = io::stdin(); let mut operators = String::new(); let mut start_value = String::new()...
true
9c478e12d2356f3851db375dbaadec3dcc96c83a
Rust
jdno/rust-67087
/library/src/lib.rs
UTF-8
1,107
2.90625
3
[]
no_license
use std::sync::{Arc, Mutex}; use tokio::sync::watch::Receiver; pub struct Bug { pub receiver: Mutex<Receiver<Arc<u32>>>, pub state: Mutex<Arc<u32>>, } impl Bug { pub async fn run(&self) { loop { let mut receiver = self.receiver.lock().unwrap(); if let Some(broadcast) = rec...
true
62244da7df53e3f2439bc13423a69b0e29b59439
Rust
synlestidae/rustorrent
/src/tracker/http.rs
UTF-8
2,564
2.671875
3
[ "Apache-2.0" ]
permissive
use tracker::data::{TrackerReq, TrackerResp}; use bencode::Bencode; use bencode::decode::{belement_decode, DecodeResult}; use bencode::BDict; use hyper::Url; use hyper::client::Request; use hyper::client::Client; use hyper::net::HttpStream; use std::error::Error; use std::fmt; use std::io::Read; use convert::TryFrom; u...
true
1c8a62ed2b61cb9b777b738f22bdafc88b33a709
Rust
andreev-io/Advent-of-Code-2020
/day14/main.rs
UTF-8
4,088
3
3
[]
no_license
#![feature(destructuring_assignment)] use lazy_static::lazy_static; use regex::Regex; use std::collections::BTreeMap; use std::collections::HashMap; use std::{fs::File, io, io::prelude::*}; // THIS WILL NOT WORK ON 32 BIT SYSTEMS! // https://topaz.github.io/paste/#XQAAAQDzDAAAAAAAAAAxm8oZxjYXQyz+h0Ec7PrIkqovpxcvrxTHae...
true
f038b3cce1e33743b85d268611d43b3270736d27
Rust
Ranovan7/oxidation_example
/examples/some_options.rs
UTF-8
476
3.25
3
[]
no_license
use playground::belongings::*; fn plus_one(x: Option<i32>) -> Option<i32> { match x { None => None, Some(i) => Some(i + 1), } } fn main() { let five = Some(5); let six = plus_one(five); let none = plus_one(None); println!("'six' value is : {:?}", six.unwrap()); // println!...
true
81aefd93787cef24a399f48ad84b823d710995e5
Rust
xanahopper/leetcode
/src/leetcode/biweekly/biweekly_83_1.rs
UTF-8
948
2.9375
3
[]
no_license
use crate::leetcode::Solution; #[test] fn biweekly_83_1_test() { assert_eq!(Solution::best_hand(vec![13,2,3,1,9], vec!['a', 'a', 'a', 'a', 'a']), "Flush"); assert_eq!(Solution::best_hand(vec![4,4,2,4,4], vec!['d', 'a', 'a', 'b', 'c']), "Three of a Kind"); assert_eq!(Solution::best_hand(vec![10,10,2,12,9], ...
true
11330cccf88a9969567efbc571d085e512d22d18
Rust
WooZoo86/ruffle
/core/src/avm1/value.rs
UTF-8
5,344
3.15625
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use crate::avm1::object::Object; use crate::avm1::{ActionContext, Avm1, Error}; use gc_arena::GcCell; #[derive(Clone, Debug)] #[allow(dead_code)] pub enum Value<'gc> { Undefined, Null, Bool(bool), Number(f64), String(String), Object(GcCell<'gc, Object<'gc>>), } unsafe impl<'gc> gc_arena::Colle...
true
326711dac5e3bd9ff2114d82264b806b9e47155d
Rust
AntonyBlakey/ceramic
/src/layout/floating_layout.rs
UTF-8
1,318
2.71875
3
[ "MIT" ]
permissive
use crate::{artist::Artist, commands::Commands, layout::*, window_data::WindowData}; pub fn new(child: Box<dyn Layout>) -> Box<FloatingLayout> { Box::new(FloatingLayout { child }) } pub struct FloatingLayout { child: Box<dyn Layout>, } impl Layout for FloatingLayout { fn layout( &self, re...
true
275c10c6ff772819f7de99f977f7adc6f3636315
Rust
moshg/rust-std-ja
/src/test/run-pass/self-impl.rs
UTF-8
1,906
2.859375
3
[ "MIT", "BSD-3-Clause", "NCSA", "Apache-2.0", "LicenseRef-scancode-other-permissive", "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
edda4d2e6147b3f1b9025d5350b87fd7add5d484
Rust
bmdelacruz/blog-os
/src/memory.rs
UTF-8
2,468
2.53125
3
[]
no_license
use bootloader::bootinfo::MemoryMap; use bootloader::bootinfo::MemoryRegionType; use x86_64::PhysAddr; use x86_64::VirtAddr; use x86_64::registers::control::Cr3; use x86_64::structures::paging::{ FrameAllocator, Mapper, Page, PageTable, PageTableFlags as Flags, PhysFrame, Size4KiB, MapperAllSizes, MappedPageTable, ...
true
f6f687cfdfdf4eb21c861ae972291162aeb06d68
Rust
MichaelHe1125/rust-leetcode
/src/p0066_plus_one.rs
UTF-8
1,620
4.0625
4
[]
no_license
// 66. Plus One // Easy // Given a non-empty array of digits representing a non-negative integer, plus one to the integer. // The digits are stored such that the most significant digit is at the head of the list, and each element in the array contain a single digit. // You may assume the integer does not contain any...
true
d3e38d0bdfaae22bbc9ef0a7d0af01ed0665f9b4
Rust
bjoeris/rust-immutable-seq
/src/tree23.rs
UTF-8
5,343
3.015625
3
[ "MIT" ]
permissive
use std::rc::Rc; use lazy::static_fn::Lazy; use self::Tree23::{Leaf,Node2,Node3}; use measure::Measure; use monoid::Monoid; pub enum Tree23<T, M> { Leaf(T), Node2(M, Lazy<Tree23<T,M>>, Lazy<Tree23<T,M>>), Node3(M, Lazy<Tree23<T,M>>, Lazy<Tree23<T,M>>, Lazy<Tree23<T,M>>), } impl<T,M> Tree23<T,...
true
0ff84f28bcda6091491bc197533e849ac5cd363f
Rust
lucascaro/rust-game_of_life
/src/sample.rs
UTF-8
1,483
2.859375
3
[]
no_license
#[allow(dead_code)] pub fn small_start(w: usize, h: usize) -> Vec<Vec<bool>> { debug!("creating grid of {}x{}", w, h); let mut v = vec![vec![false; h]; w]; // debug!("created grid of {:?}", v); v[w / 2 - 1][h / 2] = true; v[w / 2][h / 2 + 1] = true; v } #[allow(dead_code)] pub fn clustering(w: ...
true
3f059318bc871fb7fc751594a24d64d4b81b5fd2
Rust
lumeohq/onvif-rs
/xsd_rs/types/src/lib.rs
UTF-8
3,778
2.625
3
[ "MIT" ]
permissive
#![allow(clippy::derive_partial_eq_without_eq)] use std::str::FromStr; use validate::Validate; use xsd_macro_utils::*; use yaserde_derive::{YaDeserialize, YaSerialize}; // Type used to reference logical and physical entities. // Token may be extended by intermediate terminal with adding prefix to make it // global un...
true
5751ebb410eacd1ead63b59a30317ff952f0adec
Rust
dimasjt/i-like-rust
/shape/src/lib.rs
UTF-8
399
3.4375
3
[]
no_license
use std::f32::consts::PI; #[derive(Debug)] pub struct Rectangle { pub width: u32, pub height: u32, } impl Rectangle { pub fn area(&self) -> u32 { self.width * self.height } } #[derive(Debug)] pub struct Circle { pub diameter: f32, } impl Circle { pub fn area(&self) -> f32 { l...
true
293fe8aab1313c00323bed2d7990ec7e924fbcca
Rust
david0u0/adams-leaf
/src/recorder/flow_table/mod.rs
UTF-8
3,400
2.953125
3
[]
no_license
pub mod prelude; #[derive(Clone, PartialEq, Eq, Debug)] pub enum OldNew<T: Clone + Eq> { New(T), Old(T), } mod iter { use super::OldNew; use crate::flow::{FlowEnum, FlowID}; pub enum Iter<'a, F: From<&'a FlowEnum>, T: Clone + Eq> { FlowTable { ptr: usize, cur_list: ...
true
2033a0dc4152b2b87c3fc87e1c42437bd79c7692
Rust
Ninjani/rosalind
/s_dna/src/lib.rs
UTF-8
1,050
3.34375
3
[ "MIT" ]
permissive
use anyhow::Error; use std::path::Path; /// Counting DNA Nucleotides /// /// Given: A DNA string s of length at most 1000 nt. /// /// Return: Four integers (separated by spaces) counting the respective number of times /// that the symbols 'A', 'C', 'G', and 'T' occur in s. pub fn rosalind_dna(filename: &Path) -> Resu...
true
80c5866340943c357e7a409767c99a9e2150426e
Rust
GigameshGarages/FileMint
/SimpleFileReader.rs
UTF-8
231
2.796875
3
[ "Apache-2.0" ]
permissive
use std::env; use std::fs; fn main() { println!("In file {}", filename); let contents = fs::read_to_string(filename) .expect("Something went wrong reading the file"); println!("With text:\n{}", contents); }
true
f7b4dbb6ef670e4ae591a529783cb912fa7c6d7a
Rust
bauhaus93/test-backend
/src/utility/settings.rs
UTF-8
1,051
3.171875
3
[]
no_license
use std::collections::HashMap; use config::{Config, File}; lazy_static! { static ref SETTINGS: HashMap<String, String> = { let mut settings = Config::default(); match settings.merge(File::with_name("settings")) { Ok(_) => info!("Loaded settings file"), Err(e) => warn!("Could...
true
d7434fa5ca5c273c7ef38c9c4257eaa619706843
Rust
8573/derive-checked-builder.rs
/tests/eddyb-1.rs
UTF-8
823
3.234375
3
[]
no_license
#[macro_use] extern crate derive_checked_builder; #[derive(CheckedBuilder)] struct Foo { a: String, b: i32, c: [u8; 3], #[builder(default = "\"def\"")] d: String, #[builder(default(8))] e: u16, } impl FooBuilder<String, i32, [u8; 3]> { fn format(self) -> String { format!( ...
true
178c6c054f1bcf9c93753f9c5d8ea70726bf562b
Rust
crossterm-rs/terminal
/src/backend/crossterm/implementation.rs
UTF-8
5,030
2.796875
3
[ "MIT" ]
permissive
use std::{io, io::Write}; use crossterm::{ cursor, event, style, terminal, terminal::{disable_raw_mode, enable_raw_mode}, ExecutableCommand, QueueableCommand, }; use crate::{backend::Backend, error, error::ErrorKind, Action, Event, Retrieved, Value}; pub struct BackendImpl<W: Write> { // The internal...
true
2fe70f105a627adcebf6777bfc66bd30ddd44066
Rust
JohnFinn/robot
/src/world_draw.rs
UTF-8
4,393
2.59375
3
[]
no_license
extern crate ggez; extern crate nalgebra; type Vector2 = nalgebra::Vector2<f32>; use ggez::{Context, GameResult, conf, ContextBuilder, event}; use ggez::graphics::{Point2, Drawable}; use ggez::event::EventHandler; use ggez::graphics::{self, DrawMode, DrawParam}; use crate::world::*; use std::rc::Rc; use std::cell::...
true
fc21b1568355cce85f65fdde1b91d16d38a4d0ab
Rust
GCBallesteros/tttr-toolbox
/tttr-toolbox/src/tttr_tools/circular_buffer.rs
UTF-8
1,579
3.328125
3
[]
no_license
pub(super) struct CircularBuffer { buffer: Vec<u64>, pub head: i64, } impl CircularBuffer { pub fn new(buffer_size: usize) -> Self { Self { buffer: Vec::with_capacity(buffer_size), head: 0, } } #[inline(always)] pub fn push(&mut self, val: u64) { ...
true
819809dab8e1348ce6c7f74ec54ca53e4adbb999
Rust
byronwasti/movine
/src/match_maker.rs
UTF-8
2,507
3
3
[ "MIT" ]
permissive
use crate::migration::Migration; use std::cmp::Ordering; use std::collections::HashMap; pub fn find_matches<'a>( local_migrations: &'a [Migration], db_migrations: &'a [Migration], ) -> Vec<Matching<'a>> { let mut matches = Vec::new(); let mut local_cmp: HashMap<&str, &Migration> = local_migrations ...
true
63c2fbdc8f09e5e4e5a2d13b00a45232ca668c27
Rust
zakmagnus/rust_poker_odds
/poker_odds/src/main.rs
UTF-8
12,210
2.765625
3
[]
no_license
extern crate rand; extern crate getopts; extern crate num_cpus; extern crate cards; extern crate poker_hands; use std::env; use std::collections::HashMap; use std::str::FromStr; use std::thread; use std::sync::*; use getopts::{Options, Matches, HasArg, Occur}; use rand::{thread_rng, Rng}; use cards::{Card, Rank, Suit...
true
230218f50436db15a4ab97987f5e09934f3e7519
Rust
YaLTeR/vapoursynth-rs
/vapoursynth/src/tests.rs
UTF-8
33,655
2.53125
3
[ "MIT", "Apache-2.0" ]
permissive
#![cfg(test)] use super::*; // We need the VSScript functions, and either VSScript API 3.2 or the VapourSynth functions. #[cfg(all( feature = "vsscript-functions", any(feature = "vapoursynth-functions", feature = "gte-vsscript-api-32") ))] mod need_api_and_vsscript { use std::ffi::CStr; use std::fmt::D...
true
8e6bf4900983bedebf09f6e9d1721445f50c8082
Rust
maaslalani/ntbk
/src/util.rs
UTF-8
2,250
2.953125
3
[ "MIT" ]
permissive
use crate::config; use dialoguer::{Select,Input,Confirm,theme}; use std::{fs,result,io,env}; pub fn choose_note() -> String { let options = list_notes(); let theme = theme::ColorfulTheme::default(); let selection = match Select::with_theme(&theme) .default(0) .items(&options[..]) .i...
true
1e9ca8c341784bdbcf5f591f5aab4d4ee937efb0
Rust
RedDocMD/n-queens
/src/bin/full_board.rs
UTF-8
1,168
3.140625
3
[ "MIT" ]
permissive
use nqueens::board::*; use std::env::args; fn main() { let size: usize; if let Some(num) = args().nth(1) { size = num.parse().unwrap(); } else { size = 8; } let (moves, tries, solution) = restart_hill_climb(size); assert!(solution.is_goal()); println!("{}", solution); println!("In {} moves", mo...
true
9b00a42d1b22405b23b1d22b2363433a11aff948
Rust
mihajlo-jovanovic/advent-of-code
/2022/rust/src/day4.rs
UTF-8
1,849
3.265625
3
[]
no_license
use std::str::Split; use aoc_runner_derive::{aoc, aoc_generator}; type Range = (u8, u8); fn contains(this: &Range, other: &Range) -> bool { this.0 <= other.0 && this.1 >= other.1 } fn overlaps(this: &Range, other: &Range) -> bool { (this.0 <= other.0 && this.1 >= other.0) || (other.0 <= this.0 && other.1 >=...
true
6dd4afac29d597a4eb65e214309ebcdb9a2fe560
Rust
imor/lunatic
/uptown_funk/tests/wasmtime_custom_type_reference_test.rs
UTF-8
1,788
2.78125
3
[ "MIT", "Apache-2.0" ]
permissive
use uptown_funk::{host_functions, HostFunctions, InstanceEnvironment}; use wasmtime::*; use std::fs::read; struct InstanceState {} impl InstanceEnvironment for InstanceState { fn wasm_memory(&self) -> &mut [u8] { &mut [] } } struct NumberState { saved_number: MyNumber, } #[host_functions(namesp...
true
d2908891fbf0f1b7e76aa49bf568b4448e2e6515
Rust
frankegoesdown/LeetCode-in-Go
/Algorithms/0632.smallest-range/smallest-range_test.go
UTF-8
675
2.5625
3
[ "MIT" ]
permissive
package problem0632 import ( "fmt" "testing" "github.com/stretchr/testify/assert" ) // tcs is testcase slice var tcs = []struct { nums [][]int ans []int }{ { [][]int{{4, 10, 15, 24, 26}, {0, 9, 12, 20}, {5, 18, 22, 30}}, []int{20, 24}, }, { [][]int{{1, 2, 3}, {1, 2, 3}, {1, 2, 3}}, []int{1, 1}, }...
true
389b64221e25722f21cd1fa6fbd078b653a76912
Rust
SuperFluffy/gramschmidt-rs
/examples/lauchli.rs
UTF-8
3,040
2.59375
3
[ "MIT" ]
permissive
extern crate openblas_src; use gramschmidt::{ cgs, cgs2, mgs }; use lapacke::dlange; use ndarray::{ Array2, ArrayBase, Data, Ix2, s, }; fn create_lauchli(n: usize, epsilon: f64) -> Array2<f64> { let mut matrix = Array2::<f64>::zeros((n+1, n)); matrix .row_mut(0) ...
true
61f0d52096484acd4acffa7e9c16709fe07c6b3b
Rust
genchev99/rust-game
/src/movement_helpers.rs
UTF-8
3,229
3.09375
3
[]
no_license
use ggez::event::KeyCode; use ggez::{graphics}; use rand::{ distributions::{Distribution, Standard}, Rng, }; use crate::config::{GRID_CELL_SIZE, GRID_SIZE}; use ggez::graphics::mint; use ggez::mint::Point2; #[derive(Clone, Copy, PartialEq, Debug)] pub struct GridPosition { x: f32, y: f32, } impl GridP...
true
51dafc1ecd8e1a7c1eab6b3fbab5ca1166b7b00d
Rust
ConnorTroy/smartcast
/tests/local.rs
UTF-8
1,024
2.90625
3
[ "MIT" ]
permissive
use smartcast::Device; /// These tests will only work if there is a SmartCast device on the local network. Otherwise they will just pass. #[tokio::test] async fn find_by_ip() { let devices = smartcast::discover_devices().await.unwrap(); for dev in devices { if let Ok(same_dev) = Device::from_ip(dev.ip(...
true
4cff9a4b2d1d14873a3e2f8a5dc9167c26fb5d0b
Rust
spin6lock/rust_json_to_yaml
/src/main.rs
UTF-8
1,153
2.90625
3
[]
no_license
use std::fs::File; use std::io::Read; use std::str; extern crate clap; use clap::{Arg, App}; use serde_json::{Value}; fn parse_args() -> String { let matches = App::new("json to yaml convertor") .version("0.1.0") .author("spin6lock") .about("...
true
cbacd153b24972deca81c13dcfe82eb12c886cbd
Rust
dkomlen/learning
/rust/slices/src/main.rs
UTF-8
437
3.3125
3
[]
no_license
fn print(x: &str) { println!("{}", x); } fn print_vector(xs: &Vec<i32>) { println!("{:?}", xs); } fn print_array(xs: &[i32]) { println!("{:?}", xs); } fn main() { let a = String::from("test"); print(a.as_str()); let mut b = "hello world"; print(b); b = "new hello world"; print(b...
true
20ada9cb21fba4b9bb064f3443f7908ec9cd78ac
Rust
alessioalex/rustbook
/src/6.3_control_flow_if_let.rs
UTF-8
389
3.390625
3
[]
no_license
fn main() { let some_u8_value = Some(0u8); /* match some_u8_value { Some(3) => println!("three"), _ => (), } // alternative below */ if let Some(3) = some_u8_value { println!("three"); } else if let Some(0) = some_u8_value { println!...
true
17d4d56e94eaf801e5e829c0f568f9202f1f0f73
Rust
frenicth/tock
/chips/nrf51/src/trng.rs
UTF-8
4,301
2.84375
3
[ "Apache-2.0", "MIT" ]
permissive
//! TRNG driver for nrf51dk //! //! The TRNG generates 1 byte randomness at the time value in the interval //! 0 <= r <= 255 //! //! The capsule requires 4 bytes of randomness //! //! The counter "done" ensures that 4 bytes of randomness have been generated //! before returning to the capsule. //! //! A temporary array...
true
ba448aad23cd281941aad3c0617538ad3c32d674
Rust
sigod/codewars
/src/whats-up-next.rs
UTF-8
515
3.421875
3
[ "MIT" ]
permissive
fn next_item<T: PartialEq<T> + Clone>(slice: &[T], find: T) -> Option<T> { let mut i = 0; for v in slice { if v == &find { if i + 1 < slice.len() { return Some(slice[i + 1].clone()); } break; } i += 1; } return None; } #[test] fn returns_expected() { assert_eq!(next_item(&["Joe", "Bob", "Sal...
true
21a11d9267670b8b9dce6fc7844f831a0e8df573
Rust
icemanx7/ray-tracer
/src/weekend.rs
UTF-8
739
2.984375
3
[]
no_license
use crate::{ hittable::{HitRecord, Hittable, Sphere}, ray::Ray, vec3::{dot, Vec3}, }; use rand::Rng; use std::sync::Mutex; use std::{f64::consts::PI, ops::Deref, sync::Arc}; // inline double degrees_to_radians(double degrees) { // return degrees * pi / 180; // } fn degrees_to_radians(degrees: f64) -> f...
true
6dc6464625797ec8cc291cdf26532dc5f68ae4c3
Rust
AerialX/no-io.rs
/src/sync_traits.rs
UTF-8
9,702
2.828125
3
[]
no_license
use core::fmt; use core::convert::Infallible; use super::{AllError, Take}; #[cfg(feature = "ufmt")] use super::uWriter; pub(crate) mod prelude { pub use super::{Read, ReadExt, Write, WriteExt}; } // TODO: pull the provided fns out into extension traits instead? pub trait Read { type Error; fn read(&mut ...
true
e5a07fe242845ec97ab2d09aab754278d2ba3dd8
Rust
xcf-t/simple-iu
/src/main.rs
UTF-8
4,347
2.515625
3
[]
no_license
mod config; mod api_key; mod utils; #[macro_use] extern crate rocket; #[macro_use] extern crate lazy_static; use std::collections::HashMap; use std::path::Path; use std::str::FromStr; use rocket::{State, Data}; use rocket::data::ByteUnit; use crate::config::{UploadConfig, UploadState}; use crate::api_key::User; use ...
true
268680461329d8e24355cabdbde711586501fa5a
Rust
w23/SUCKS
/src/exit.rs
UTF-8
959
2.546875
3
[]
no_license
/* use tokio::net::{UdpSocket}; use std::io::Cursor; use byteorder::ReadBytesExt; async fn connectionCreate(addr: &std::net::SocketAddr, cur: &mut Cursor<&[u8]>) -> Result<(), Box<dyn std::error::Error>> { Ok(()) } async fn connectionHandle(addr: &std::net::SocketAddr, cur: &mut Cursor<&[u8]>) -> Result<(), Box<d...
true
e6897d6b87ba644dd90cdb1698d7dfe56436de10
Rust
o0Ignition0o/yewprint
/yewprint/src/lib.rs
UTF-8
3,924
2.734375
3
[ "MIT" ]
permissive
mod buttons; mod callout; mod card; mod collapse; mod html_elements; mod icon; mod menu; mod progressbar; mod switch; #[cfg(feature = "tree")] mod tree; pub use buttons::*; pub use callout::*; pub use card::*; pub use collapse::*; pub use html_elements::*; pub use icon::*; #[cfg(feature = "tree")] pub use id_tree; pub...
true
902638966899d95e6ce14ded9347db2865b21714
Rust
WofWca/rust-life
/src/lib.rs
UTF-8
9,376
3.046875
3
[]
no_license
extern crate termion; pub mod game { #[derive(Copy, Clone, PartialEq, Debug)] #[repr(u8)] pub enum CellState { Dead = 0, Alive = 1, } use CellState::Alive; use CellState::Dead; pub type CellsRow = Vec<CellState>; pub type Cells = Vec<CellsRow>; // All rows must have the...
true
534f23a99f02de8dc8cf72e742b52775240eda14
Rust
SchrodingerZhu/genetic-algo-opt
/src/graph.rs
UTF-8
335
2.671875
3
[]
no_license
use anyhow::*; use std::path::Path; #[derive(serde::Deserialize)] pub struct Graph { pub edges: Vec<(usize, usize, usize)>, pub sizes: Vec<usize>, } pub fn load_raw_data<S: AsRef<Path>>(path: S) -> Result<Graph> { let reader = std::fs::File::open(path.as_ref())?; simd_json::from_reader(reader).map_err...
true