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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
f9657fed9e27eeeda5b68384ba4ac8962e3f48df | Rust | Sousa99/AdventOfCode2020 | /day_22/src/main.rs | UTF-8 | 10,451 | 3.21875 | 3 | [
"MIT"
] | permissive | use std::fs::File;
use std::io::{BufRead, BufReader};
use std::collections::VecDeque;
// TODO:
// Maybe a bit of refactoring, altough not bad, it could be more straighforward
const DEBUG : bool = false;
// ------------------ Processing Phase ------------------
enum ProcessingPhase {
PlayerIdentifier,
PlayerC... | true |
a80a17832cc4a5cc37e6c8fa4a577d0125efbac6 | Rust | willi-kappler/rayon | /src/log.rs | UTF-8 | 1,299 | 2.53125 | 3 | [] | no_license | //! Debug Logging
use job::Job;
use latch::SpinLatch;
use std::sync::atomic::{AtomicUsize, ATOMIC_USIZE_INIT};
#[allow(dead_code)]
#[derive(Debug)]
pub enum Event {
StartWorking { index: usize },
InjectJobs { count: usize },
WaitForWork { worker: usize, was_active: bool },
StoleWork { worker: usize, j... | true |
2d765c7dd6fc7b78039cb776ebef0ac8c60e79cd | Rust | mabruckner/starfield-render | /src/bin/perspective.rs | UTF-8 | 1,648 | 2.640625 | 3 | [] | no_license | extern crate starfield_render;
extern crate nalgebra;
use starfield_render as sf;
use nalgebra::{
Vector4,
Vector3,
Vector2,
dot,
Rotate,
Rotation3
};
fn print_mat(buf: &sf::DepthBuffer<sf::Pixel>)
{
for y in (0..buf.height).rev() {
println!("{}", sf::make_colorstring(buf.row_iter... | true |
2d0e443a50ef8a795f42c748d41fb4bacfd4a6b3 | Rust | rust-lang/rustc-perf | /collector/compile-benchmarks/style-servo/components/script/task.rs | UTF-8 | 2,697 | 2.84375 | 3 | [
"MIT"
] | permissive | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//! Machinery for [tasks](https://html.spec.whatwg.org/multipage/#concept-task).
use std::fmt;
use std::intrinsic... | true |
9fd9c7a4436b467b54bfbd51a661132ce536a5eb | Rust | IDragnev/myos | /src/allocator/fixed_size_block.rs | UTF-8 | 7,807 | 3.015625 | 3 | [] | no_license | use super::{
Locked,
};
use alloc::alloc::{
Layout,
GlobalAlloc,
};
use core::{
ptr::{
self,
NonNull,
},
mem,
};
struct Node {
next: Option<&'static mut Node>,
}
/// Represents the layout of a fixed-size block.
#[derive(Copy, Clone, Debug)]
struct BlockLayout {
size: us... | true |
54743e4cc7a7b76e4cade36e5e789b3e13073ab8 | Rust | gyn/exercism | /rust/hamming/src/lib.rs | UTF-8 | 291 | 3.203125 | 3 | [
"BSD-2-Clause"
] | permissive | pub fn hamming_distance(a: &str, b: &str) -> Result<usize, &'static str> {
if a.len() != b.len() {
return Result::Err("Length is not same");
}
let count = a.chars()
.zip(b.chars())
.filter(|&(an, bn)| an != bn)
.count();
Result::Ok(count)
}
| true |
438fd890a8d7d4bc3298e3e3b926dbda9048ce53 | Rust | pombredanne/chm-hash-rs | /src/lib.rs | UTF-8 | 3,164 | 3.09375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0",
"MIT"
] | permissive | use crate::graph::Graph;
use crate::hash::BytesHash;
mod graph;
mod hash;
#[derive(Debug, Clone)]
pub struct PerfectHash {
salt1: Vec<usize>,
salt2: Vec<usize>,
graph: Vec<usize>,
}
impl PerfectHash {
pub fn new(salt1: Vec<usize>, salt2: Vec<usize>, graph: Vec<usize>) -> Self {
assert_eq!(sal... | true |
b75eb942f4193b2e010746c22a701d03a0057008 | Rust | aDotInTheVoid/noria | /orchestration/src/vote/backends.rs | UTF-8 | 1,444 | 2.5625 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | #[derive(Debug, PartialEq, Eq)]
pub(crate) enum Backend {
Netsoup { shards: Option<usize> },
Mssql,
Mysql,
Memcached,
Hybrid,
}
impl Backend {
pub(crate) fn multiclient_name(&self) -> &'static str {
match *self {
Backend::Netsoup { .. } => "netsoup",
Backend::Mss... | true |
d3d59697db71a7a87ba941307cc3ed5262d1c1c8 | Rust | linclelinkpart5/anagma | /src/util/mod.rs | UTF-8 | 6,007 | 3.296875 | 3 | [
"MIT"
] | permissive | pub mod file_walker;
pub(crate) mod ooms;
pub use self::file_walker::FileWalker;
use std::fs::Metadata;
use std::io::Result as IoResult;
use std::path::{Path, Component};
use std::time::SystemTime;
use thiserror::Error;
#[derive(Debug, Clone, Copy, Error, PartialEq, Eq, Hash)]
pub enum InvalidNameKind {
#[error... | true |
ce2c03b4e25837855cfbb0d4d8979541e7dd45cc | Rust | ilya-epifanov/heim | /heim-process/src/sys/linux/process/procfs/paths.rs | UTF-8 | 643 | 2.546875 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use heim_common::Pid;
use std::path::{Path, PathBuf};
use heim_runtime as rt;
pub fn process_file_path<T: AsRef<Path>>(pid: Pid, filename: T) -> PathBuf {
// It should be max up to 2^22, so 7 bytes should be enough to squeeze string representation of pid?
static MAX_PID_LENGTH: usize = 7usize;
let procfs_... | true |
4f939a28489619ed8588641e417a089b37ad4762 | Rust | jimmac/ashpd | /src/desktop/screenshot.rs | UTF-8 | 8,473 | 3.3125 | 3 | [
"MIT"
] | permissive | //! # Examples
//!
//! ## Taking a screenshot
//!
//! ```rust,no_run
//! use ashpd::desktop::screenshot;
//! use ashpd::WindowIdentifier;
//!
//! async fn run() -> ashpd::Result<()> {
//! let uri = screenshot::take(&WindowIdentifier::default(), true, true).await?;
//! println!("URI: {}", uri);
//! Ok(())
//... | true |
30b17b6410071a1b9ced2bff47ccdffb4b130a5a | Rust | tengrommel/chip8 | /src/main.rs | UTF-8 | 1,162 | 3.25 | 3 | [] | no_license | use async_std::task::{block_on, sleep};
use std::{thread, time};
use futures::future::join;
async fn hello() {
println!("Hello");
}
async fn connect_db() -> String {
sleep(time::Duration::from_secs(1)).await;
String::from("db client")
}
async fn with_result() -> Result<String, ()> {
Ok(String::from("... | true |
ca965461bda1a8d009b2eeedbf7979691b718357 | Rust | sashinexists/advent-of-code-2020-rust | /src/day4part1.rs | UTF-8 | 1,055 | 3.25 | 3 | [] | no_license | use aocf::Aoc;
pub fn run() {
let input = read_input();
let passports = process_input(&input);
println!("There are {} valid passports.", count_valid_passports(passports));
}
fn count_valid_passports(passports:Vec<&str>) -> i32
{
let mut count:i32 = 0;
for passport in passports{
if validate... | true |
4c40f7459fdfc635d584134c03d2907c9947af70 | Rust | BinaryBearzz/analog-multiplexer | /examples/bluepill/examples/channels/mod.rs | UTF-8 | 2,932 | 3.46875 | 3 | [
"Apache-2.0"
] | permissive | //! This little module provides a place to store analog channel data (`ChannelValues`)
//! and also provides a super user-friendly channel data viewing experience
//! via `core::fmt::Display`. Only meant for the examples but if you so desire
//! feel free to copy it into your own code for use with debugging.
// Struc... | true |
99961f5e4f1670be87b70cf582b7bb2172059651 | Rust | moxaj/friendly-octopus | /src/server/observe.rs | UTF-8 | 404 | 2.984375 | 3 | [] | no_license | pub trait Observable<'a, T: 'a> {
fn subscribe_observer(&mut self, observer: &'a impl Observer<T>);
fn get_value(&'a self) -> &'a T;
fn get_observers(&self) -> &[&dyn Observer<T>];
fn notify_observers(&'a self) {
for &observer in self.get_observers() {
observer.notify(self.get_val... | true |
6cc7fc9aa89c6019a0247599eece5ce07ef0a6dc | Rust | yuanlang/web-app-languages-benchmarks | /ConcurrentDispatchThroughput/rust/dispatcher/src/connector.rs | UTF-8 | 4,524 | 2.9375 | 3 | [
"MIT"
] | permissive |
use crate::{Command, MSG_LEN, get_timestamp, TIMESTAMP_LEN};
use tokio::sync::mpsc;
use std::sync::{Arc, Mutex};
use log::{debug, error, info};
use tokio::io::{AsyncReadExt, AsyncWriteExt};
#[derive(Debug)]
pub struct Connector {
id: u32,
stream: tokio::net::TcpStream,
rx_from_master: tokio::sync::onesh... | true |
1d0490ed7abc5644061f06ca62d2405755505fc3 | Rust | Walters-Kuo/book-tw | /listings/ch12-an-io-project/listing-12-05/src/main.rs | UTF-8 | 603 | 2.765625 | 3 | [
"Apache-2.0",
"BSD-3-Clause",
"NCSA",
"LicenseRef-scancode-public-domain",
"BSD-2-Clause",
"MIT",
"Unlicense",
"LicenseRef-scancode-other-permissive"
] | permissive | use std::env;
use std::fs;
// ANCHOR: here
fn main() {
let args: Vec<String> = env::args().collect();
let (query, filename) = parse_config(&args);
// --省略--
// ANCHOR_END: here
println!("搜尋 {}", query);
println!("目標檔案為 {}", filename);
let contents = fs::read_to_string(filename)
... | true |
ab0c9c5658e8faef1e270f94d4684b3246eca053 | Rust | samurailobster/rust-blockchain-1 | /protocol/tests/tests.rs | UTF-8 | 7,884 | 2.546875 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | #[macro_use]
extern crate quickcheck;
extern crate blockchain_hooks;
extern crate blockchain_protocol;
use blockchain_hooks::EventCodes;
use blockchain_protocol::BlockchainProtocol;
use blockchain_protocol::enums::status::StatusCodes;
use blockchain_protocol::payload::*;
quickcheck! {
fn test_found_block(index: u... | true |
45357fcb8981d62a12921f865bb3dba61221f52e | Rust | epfl-dias/mercator_db | /src/storage/json.rs | UTF-8 | 1,282 | 3.046875 | 3 | [
"MIT"
] | permissive | //! JSON support
use std::fs::File;
use std::io::BufWriter;
use std::io::Error;
use std::io::ErrorKind;
use memmap::Mmap;
use serde::de::DeserializeOwned;
use serde::Serialize;
fn convert<T>(from: &str, to: &str) -> Result<(), Error>
where
T: Serialize + DeserializeOwned,
{
let file_in = File::open(from)?;
... | true |
0013d0c343e4c8b0254039d4909818275dfcc4d7 | Rust | henrikpersson/potatis | /mos6502/src/instructions.rs | UTF-8 | 22,273 | 3.25 | 3 | [
"MIT"
] | permissive | use crate::address_mode::AddressMode;
use crate::cpu::Cpu;
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
#[allow(clippy::upper_case_acronyms)]
pub enum Opcode {
ADC, // Add Memory to Accumulator with Carry
SBC, // Subtract Memory from Accumulator with Borrow
CLD, // Clear decimal mode
CLC, // Clear carry
... | true |
7d95eb38509547698c39dd4b7bb21dfbf16a4d36 | Rust | NeoTim/xsecurelock-saver-rs | /saver_genetic_orbits/src/pruner.rs | UTF-8 | 3,115 | 2.859375 | 3 | [
"Apache-2.0"
] | permissive | // Copyright 2018 Google LLC
//
// 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 |
43a9c2b06caa9f493144a9871ce3a5627f6578c5 | Rust | josephlr/rak | /tests/qemu.rs | UTF-8 | 1,505 | 2.59375 | 3 | [] | no_license | //! Load and run the no-std binary
use std::{fs::File, path::Path, process::Command};
fn get_kernel_path() -> impl AsRef<Path> {
// Ideally this function would just return env_path. However, this path
// currently points to the kernel built for the host target, rather than
// our custom target. So we have ... | true |
06b140781b8aca5db8c6f4fc5b29db5e03b2d7c0 | Rust | redeyes2015/til | /rust/01_hanoi/src/main.rs | UTF-8 | 316 | 3.03125 | 3 | [] | no_license | fn hanoi (to_move: i32, from : char, to: char, via: char) {
if to_move == 0 {
return
}
hanoi(to_move - 1, from, via, to);
println!("Move {} from {} to {}", to_move, from, to);
hanoi(to_move - 1, via, to, from);
}
fn main() {
println!("Hello, world!");
hanoi(10, 'A', 'C', 'B');
}
| true |
659b4c42e436f63ca3efd408ce183294cc513a79 | Rust | simd-lite/simd-json | /src/value/owned/cmp.rs | UTF-8 | 5,293 | 2.984375 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use super::Value;
use crate::{prelude::*, BorrowedValue};
#[allow(clippy::cast_sign_loss, clippy::default_trait_access)]
impl PartialEq<BorrowedValue<'_>> for Value {
#[inline]
#[must_use]
fn eq(&self, other: &BorrowedValue<'_>) -> bool {
match (self, other) {
(Self::Static(s1), Borrowe... | true |
c9e83e9fa02734a2579eebc56164c8665e883999 | Rust | Eustaquio122/rust-tetris | /src/main.rs | UTF-8 | 813 | 2.6875 | 3 | [] | no_license | mod game;
extern crate piston_window;
extern crate opengl_graphics;
extern crate rand;
use opengl_graphics::{GlGraphics, OpenGL};
use piston_window::*;
use self::game::app::App;
fn main() {
let width: u32 = 700;
let height: u32 = 768;
let mut window: PistonWindow = WindowSettings::new("Tetris", [width, ... | true |
66c057afc81a5ef64c28a754c224b98e4c5aaed1 | Rust | jakecrim/rust_notes | /src/main.rs | UTF-8 | 15,421 | 4.0625 | 4 | [] | no_license | // Rust notes
fn main () {
let mut x = String::from("Hey there");
let mut y = String::from("Hello dawg woof");
println!("{}",first_word(&x));
println!("{}",second_word(&y));
}
fn first_word(x : &String) -> &str {
let bytes = x.as_bytes();
for (i, &item) in bytes.iter().enumerate() {
if item == b' ' {
retu... | true |
bf8bada6b7e958e58e3cee256f0129f3287ea812 | Rust | ordovicia/oci-image-rs | /image-spec/src/descriptor.rs | UTF-8 | 8,567 | 2.9375 | 3 | [] | no_license | //! Content descriptor.
//!
//! See the [OCI image spec] for more information.
//!
//! [OCI image spec]: https://github.com/opencontainers/image-spec/blob/v1.0.1/descriptor.md
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
use url::Url;
use crate::{Annotations, Digest, MediaType};
/// Content descrip... | true |
076efd802a9a97aae93292abf657c55c2783d47b | Rust | timothyhollabaugh/micromouse | /software/micromouse_logic/src/slow/mod.rs | UTF-8 | 2,757 | 2.8125 | 3 | [] | no_license | //! All of the non-realtime stuff that does not really matter how fast it runs
//!
//! Includes mapping and navigating
pub mod map;
pub mod maze;
pub mod motion_plan;
pub mod navigate;
use serde::{Deserialize, Serialize};
use crate::fast::{
Direction, Vector, DIRECTION_0, DIRECTION_3_PI_2, DIRECTION_PI, DIRECTIO... | true |
220ab1a9efb00f40afce7242783c3ade2029a6ec | Rust | chom-parser/chom | /build.rs | UTF-8 | 7,196 | 2.875 | 3 | [] | no_license | use proc_macro2::TokenStream;
use quote::quote;
use std::{
fs::{self, File},
io::{self, BufReader, Read, Write},
path::{Path, PathBuf},
};
#[derive(Debug)]
pub enum Error {
IO(io::Error),
Toml(toml::de::Error),
Data(DataError),
}
impl From<io::Error> for Error {
fn from(e: io::Error) -> Self {
Self::IO(e)
}... | true |
23bf2b36c1f7529c3d22f60c043283753977ff4c | Rust | yutiansut/actix-server-alt | /actix-http-alt/src/h1/proto/context.rs | UTF-8 | 3,318 | 3 | 3 | [
"Apache-2.0"
] | permissive | use http::header::HeaderMap;
use crate::util::date::Date;
/// Context is connection specific struct contain states for processing.
/// It needs manually reset with every new successfully decoded request.
/// See `Context::reset` method for detail.
pub(super) struct Context<'a> {
state: ContextState,
ctype: Co... | true |
02f907570e40cffa63c271bc51f113609d48d3a6 | Rust | potatosalad/cryptopals | /aes/src/ecb.rs | UTF-8 | 4,544 | 3.046875 | 3 | [] | no_license | use crate::error::AesError;
use crate::key::AesKey;
pub enum AesEcbBlockCipher {
Aes128BlockCipher(Box<aesimpl::Aes128>),
Aes192BlockCipher(Box<aesimpl::Aes192>),
Aes256BlockCipher(Box<aesimpl::Aes256>),
}
impl AesEcbBlockCipher {
pub fn new(aes_key: &AesKey) -> Self {
use aesimpl::cipher::{ge... | true |
64d79fee57e0e087542d5a488fd52881a533f74d | Rust | bjrnmrtns/xp-game-engine | /game/src/client/local_client.rs | UTF-8 | 869 | 2.75 | 3 | [] | no_license | use crate::client::client::{Receiver, Sender};
use crate::client::command::FrameCommand;
// Local client is server and client in one (loopback mode for local "networking")
pub struct LocalClient {
server_queue: Vec<FrameCommand>,
}
impl LocalClient {
pub fn new() -> LocalClient {
LocalClient {
... | true |
e1431dde1b170fd3668d193d4042c703b6b13618 | Rust | blasagna/exercism-exercises | /rust/leap/src/lib.rs | UTF-8 | 276 | 2.9375 | 3 | [] | no_license | pub fn is_leap_year(year: i32) -> bool {
let mut result: bool = false;
if year % 4 == 0 {
if year % 100 == 0 && year % 400 == 0 {
result = true;
} else if year % 100 != 0 {
result = true;
}
}
result
}
| true |
4e0377767734dce5a9bfadc5b2a36b9506970c12 | Rust | getsentry/sentry-cli | /src/commands/deploys/list.rs | UTF-8 | 1,191 | 2.75 | 3 | [
"BSD-2-Clause"
] | permissive | use anyhow::Result;
use chrono::Utc;
use clap::{Arg, ArgMatches, Command};
use crate::api::Api;
use crate::config::Config;
use crate::utils::formatting::{HumanDuration, Table};
pub fn make_command(command: Command) -> Command {
command
.about("List all deployments of a release.")
// Backward compa... | true |
fc2eca99d6007a6b418f21c3cc866ed3a3905862 | Rust | giodamelio/little_boxes | /vendor/rustix/src/fs/xattr.rs | UTF-8 | 5,958 | 2.921875 | 3 | [
"MIT",
"Apache-2.0",
"LLVM-exception"
] | permissive | use crate::{backend, io, path};
use backend::c;
use backend::fd::AsFd;
use bitflags::bitflags;
bitflags! {
/// `XATTR_*` constants for use with [`setxattr`], and other `*setxattr`
/// functions.
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
pub struct XattrFlags: c::c_uint... | true |
bf05ee6b5fb37b8d9f0df172feb394a0b1f88c4e | Rust | AngelDao/Ethereum-with-Rust-Walkthrough | /video_4/src/get_troves.rs | UTF-8 | 3,379 | 2.953125 | 3 | [] | no_license | use ethers::{
contract::Contract,
middleware::SignerMiddleware,
providers::{Http, Provider},
signers::LocalWallet,
types::Address,
};
use std::fmt;
pub struct Trove {
pub owner: Address,
pub collateral: f64,
pub debt: f64,
pub stake: f64,
pub status: String,
pub index: u16,
... | true |
63208fa30d3bffe939b536b4c4097f1ea61c6638 | Rust | n4o847/procon-rust | /accepted/judge_update_202004_d.rs | UTF-8 | 2,121 | 3.03125 | 3 | [] | no_license | use num::integer::gcd;
use proconio::{fastout, input};
use std::cmp::Ordering;
pub trait BinarySearch<T> {
fn lower_bound(&self, x: &T) -> usize;
fn upper_bound(&self, x: &T) -> usize;
fn partition_point<F>(&self, f: F) -> usize
where
F: FnMut(&T) -> bool;
}
impl<T: Ord> BinarySearch<T> for Vec... | true |
ba40762c044c601f15f589500395c07b83828a55 | Rust | willi-kappler/node_crunch | /src/nc_node.rs | UTF-8 | 24,166 | 3.328125 | 3 | [
"MIT"
] | permissive | //! This module contains the nc node message, trait and helper methods.
//! To use the node you have to implement the NCNode trait that has two methods:
//! set_initial_data() and process_data_from_server()
use std::net::{IpAddr, SocketAddr};
use std::{time::Duration};
use std::thread::{self, spawn, JoinHandle};
use s... | true |
41775591ebbfc6d4ba0509d37ca7fdbc0aeec62f | Rust | flmmkch/titlefmt | /src/function/string/caps2/mod.rs | UTF-8 | 1,218 | 2.71875 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use super::Error;
use crate::expression::{Evaluation, Expression, Value};
use crate::metadata;
pub fn caps2<T: metadata::Provider>(
expressions: &[Box<Expression<T>>],
provider: &T,
) -> Result<Evaluation, Error> {
if expressions.len() != 1 {
return Err(Error::ArgumentError);
}
let (origina... | true |
f725835e8b391978176b7ce5b84e038f12fb5722 | Rust | werner/task_remote | /src/ssh.rs | UTF-8 | 2,235 | 2.890625 | 3 | [] | no_license | use std::io::Error;
use std::io::prelude::*;
use std::net::TcpStream;
use std::path::Path;
use uuid::Uuid;
use ssh2::Session;
pub struct Ssh<'a> {
user: &'a str,
tcp: Result<TcpStream, Error>
}
impl<'a> Ssh<'a> {
pub fn new(user: &'a str, server: &'a str) -> Ssh<'a> {
Ssh {
user: user,
tcp: Tcp... | true |
448672b4a16b5857d01eb43aab2e3e1103dbc8e6 | Rust | coreylowman/projectEuler | /src/problems/problem038.rs | UTF-8 | 1,118 | 3.125 | 3 | [] | no_license | extern crate num;
use self::num::traits::PrimInt;
fn num_concat(x: u64, y: u64) -> u64 {
let l = num_length(y);
x * 10.pow(l as u32) + y
}
fn has_all(mut a: u64) -> bool {
let mut digs = [0; 10];
while a > 0 {
digs[(a % 10) as usize] += 1;
a /= 10;
}
if digs[0] > 0 {
... | true |
27f37bd393ce5b342a86ef9a8497e97b94c244ef | Rust | jDomantas/shroom | /spark-emu/src/executable.rs | UTF-8 | 3,610 | 3.0625 | 3 | [] | no_license | use std::fmt;
use std::fs;
use std::io::{self, prelude::*};
use std::path::Path;
pub const CODE_START: u64 = 1024 * 1024 * 256;
pub const DATA_START: u64 = 1024 * 1024 * 512;
pub const STACK_START: u64 = 1024 * 1024 * 511;
pub const STACK_SIZE: u64 = 1024 * 1024;
const MAGIC_STRING: [u8; 8] = *b"sparkexe";
const MAX_... | true |
ce95722aee8e07a3f8f4b416808a66ddf282f629 | Rust | shadaj/icu4x | /ffi/capi/src/locale.rs | UTF-8 | 1,311 | 2.96875 | 3 | [
"Apache-2.0",
"ICU",
"MIT",
"LicenseRef-scancode-unicode"
] | permissive | // This file is part of ICU4X. For terms of use, please see the file
// called LICENSE at the top level of the ICU4X source tree
// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).
use std::slice;
use icu_locid::Locale;
/// Opaque type for use behind a pointer, is [`Locale`]
///
/// Can be obtai... | true |
6d26194493645a66e7f995c68306639ba098f75d | Rust | magurotuna/leetcode-rust | /src/bin/22.rs | UTF-8 | 1,046 | 3.484375 | 3 | [] | no_license | struct Solution;
impl Solution {
pub fn generate_parenthesis(n: i32) -> Vec<String> {
let mut ans = Vec::new();
solve(&mut ans, 0, n, 0, "".to_string(), n);
ans
}
}
fn solve(
ans: &mut Vec<String>,
opening: i32,
rest_left: i32,
pos: i32,
cur_str: String,
n_pairs... | true |
6bca2bf0a07b973c5473e536aa5f6863ee60ce6e | Rust | msiglreith/spirv-tools-rs | /spirv-tools-sys/src/diagnostics.rs | UTF-8 | 1,295 | 2.671875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT",
"Apache-2.0"
] | permissive | #[repr(C)]
pub struct Position {
pub line: usize,
pub column: usize,
pub index: usize,
}
#[repr(C)]
pub struct Diagnostic {
pub position: Position,
pub error: *const std::os::raw::c_char,
pub is_text_source: bool,
}
#[derive(Copy, Clone, PartialEq, Debug)]
#[repr(C)]
pub enum MessageLevel {
... | true |
1e99e83c26081650ea2e2c7aaf429ab026e2188b | Rust | SuperiorJT/twilight | /http/src/request/guild/ban/create_ban.rs | UTF-8 | 4,586 | 3.1875 | 3 | [
"ISC"
] | permissive | use crate::{
client::Client,
request::{validate_inner, AuditLogReason, AuditLogReasonError, Request},
response::{marker::EmptyBody, ResponseFuture},
routing::Route,
};
use std::{
error::Error,
fmt::{Display, Formatter, Result as FmtResult},
};
use twilight_model::id::{GuildId, UserId};
/// The ... | true |
eb9cdbd8c0ed53846935570f673d4b4d2514f68c | Rust | Hossein-Noroozpour/vulkust | /vulkust/src/render/font.rs | UTF-8 | 3,284 | 2.703125 | 3 | [] | no_license | use super::super::core::gx3d::Table as Gx3dTable;
use super::super::core::object::{Base as ObjectBase, Object as CoreObject};
use super::super::core::types::Id;
use super::super::system::file::File;
use rusttype::Font as TypeFont;
use std::collections::BTreeMap;
use std::default::Default;
#[cfg(debug_mode)]
use std::fm... | true |
705e32b010c10efecc7950dac039ca6514436878 | Rust | holmrenser/lzw_kernel | /src/neighbor_joining.rs | UTF-8 | 4,254 | 2.90625 | 3 | [] | no_license | use ndarray::{Array2, Axis};
use crate::tree::{Tree, TreeNode};
pub trait NeighborJoining {
fn from_neighbor_joining(
mut dist: Array2<f64>,
names: Vec<String>
) -> Tree<TreeNode>;
}
impl NeighborJoining for Tree<TreeNode> {
fn from_neighbor_joining(
mut dist: Array2<f64>,
... | true |
fd7acd7f0a5162b4aa6e53c24b8b3b57db16bfc9 | Rust | dflemstr/serde-protobuf | /src/value.rs | UTF-8 | 9,677 | 2.984375 | 3 | [] | no_license | //! Types for representing runtime Protobuf values.
use std::collections;
use protobuf;
use protobuf::wire_format;
use crate::descriptor;
use crate::error;
/// Any protobuf value.
#[derive(Clone, Debug)]
pub enum Value {
/// A boolean value.
Bool(bool),
/// A 32-bit signed integer.
I32(i32),
/// ... | true |
4ef4da2ee53b89eccfbfbb852d7a3058aeb4f46d | Rust | pschoffer/AdventOfCode | /2021/08/src/main.rs | UTF-8 | 2,016 | 3.15625 | 3 | [] | no_license | #[path = "../../utils/parser.rs"]
mod parser;
use std::collections::HashSet;
use std::fmt;
fn main() {
// let lines = parser::parse_lines("1".to_string());
let lines = parser::parse_lines(None);
println!("Got lines {}, e.g. \"{}\"", lines.len(), lines[0]);
let mut entries: Vec<Entry> = Vec::new();
... | true |
b7f67a4537d593e179d25adb23edbd8c7065e6b6 | Rust | FabinhoB/advent_of_code_2019 | /src/crate03/Wire.rs | UTF-8 | 1,212 | 3.546875 | 4 | [] | no_license | use crate::crate03::point::Point;
pub struct Wire {
points: Vec<Point>,
}
impl Wire {
pub fn new(directions: &Vec<String>) -> Wire {
let mut points: Vec<Point> = Vec::with_capacity(0);
points.push(Point::new(0,0));
for direction_with_length in directions {
let direction = d... | true |
7a5c79dc51f2ebe9b25810e1e102b17f414040a4 | Rust | gitter-badger/kernel-2 | /src/abstractions/futures/future.rs | UTF-8 | 2,666 | 2.75 | 3 | [] | no_license |
use abstractions::poll::Poll;
use abstractions::streams::stream::IntoFuture;
use abstractions::futures::{map, map_err, then, and_then, or_else, into_stream};
use abstractions::futures::into_stream::IntoStream;
use abstractions::futures::map::Map;
use abstractions::futures::map_err::MapErr;
use abstractions::futures::... | true |
5f54f2d2b6f2d3b1bb26e3df8871d057304f1198 | Rust | bsurmanski/rust_demos | /bevy_test/src/camera.rs | UTF-8 | 1,462 | 2.65625 | 3 | [
"MIT"
] | permissive | use bevy::math::vec3;
use bevy::prelude::*;
use bevy::render::camera::Camera;
use std::ops::Add;
pub struct CameraPlugin;
impl Plugin for CameraPlugin {
fn build(&self, app: &mut App) {
app.add_startup_system(setup)
.add_system(update_camera);
}
}
#[derive(Component, Default)]
pub struct C... | true |
26e63b436f2f9bfd9f8ed30946d430233de0dfc0 | Rust | petrosagg/vaccel-rs | /src/server.rs | UTF-8 | 2,047 | 3.09375 | 3 | [] | no_license | use std::convert::TryInto;
use std::sync::atomic::{AtomicU64, Ordering};
use std::sync::Arc;
use dashmap::DashMap;
use tarpc::context::Context;
use crate::resource::{Resource, ResourceRef};
#[tarpc::service]
pub trait Vaccel {
/// Core method that registers a resource for future use
async fn register_resourc... | true |
eff47133867dd49d26fd90aaf86c1bdbcd169b62 | Rust | falconre/finch-examples | /example-0/example/src/main.rs | UTF-8 | 9,208 | 2.953125 | 3 | [
"Apache-2.0"
] | permissive | #[macro_use] extern crate error_chain;
extern crate falcon;
extern crate finch;
// We use error chain to encapsulate the different types of errors we may
// encounter.
pub mod error {
error_chain! {
types {
Error, ErrorKind, ResultExt, Result;
}
foreign_links {
Falc... | true |
3ac67cbf88a72ac3b51227883eef3e12fad09b60 | Rust | tempbottle/eventedco | /examples/tcp-echo-server.rs | UTF-8 | 2,436 | 2.578125 | 3 | [] | no_license | extern crate env_logger;
extern crate coroutine;
extern crate eventedco;
#[macro_use]
extern crate log;
extern crate clap;
use std::io::{Read, Write};
use std::thread;
use coroutine::Coroutine;
use clap::{Arg, App};
use eventedco::net::TcpListener;
use eventedco::processor::Processor;
fn main() {
let matches =... | true |
1a90c04d577ddba2f3e44706c03214011b3ebfae | Rust | josephkirk/RustLearning | /dungeon_crawling/src/save.rs | UTF-8 | 2,547 | 3.46875 | 3 | [] | no_license | #[derive(Debug)]
enum GameInput {
Option,
Quit,
Left,
Right,
Up,
Down,
Attack,
Jump,
None
}
#[derive(Debug)]
enum Input {
KeyboardInput(String),
GamepadInput(String),
}
#[derive(Debug)]
enum CharacterStrait {
Mad,
Angry,
Crazy,
Silly
}
#[derive(Debug)]
enum... | true |
8ec423c4b2ee19b73852e92023fc2f3b122e38c4 | Rust | HayaoSuzuki/tlpi | /chap04/tee/src/main.rs | UTF-8 | 1,780 | 3.0625 | 3 | [] | no_license | extern crate getopts;
use getopts::Options;
use std::env;
use std::fs::File;
use std::fs::OpenOptions;
use std::io::BufReader;
use std::io::BufWriter;
use std::io::Read;
use std::io::Write;
fn tee(out: &str, is_append: bool) -> std::io::Result<()> {
let mut output_file;
if is_append {
output_file = Op... | true |
0c85e48ab78a6f3442d1457563fd70230abe74a9 | Rust | km45/rust-studies | /projects/ch1003_lifetime/src/main.rs | UTF-8 | 1,367 | 3.890625 | 4 | [
"MIT"
] | permissive | use std::fmt::Display;
fn main() {
func1();
func2();
func3();
}
fn func1() {
let string1 = String::from("abcd");
{
let string2 = "xyz";
let result = longest(string1.as_str(), string2);
println!("The longest string is {}", result);
}
}
// lifetime annotation
// - mus... | true |
a8f6447e03b796e0e5cdb4bb4c8e18e9c0b58f33 | Rust | likr/atcoder | /arc017/src/bin/c.rs | UTF-8 | 1,477 | 2.8125 | 3 | [] | no_license | use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::f64::consts::*;
#[allow(unused)]
const INF: usize = std::usize::MAX / 4;
#[allow(unused)]
const M: usize = 1000000007;
fn... | true |
63910da0381a0102896cb522edf1fb4770e02320 | Rust | jqnatividad/qsv | /src/cmd/excel.rs | UTF-8 | 27,775 | 2.875 | 3 | [
"MIT",
"Unlicense"
] | permissive | static USAGE: &str = r#"
Exports a specified Excel/ODS sheet to a CSV file.
The first row of a sheet is assumed to be the header row.
For examples, see https://github.com/jqnatividad/qsv/blob/master/tests/test_excel.rs.
Usage:
qsv excel [options] [<input>]
qsv excel --help
Excel options:
-s, --sheet <nam... | true |
ef77b6bee57f6c44d7ab16f93bd384e6772b9162 | Rust | AcrylicShrimp/mazemaze | /src/main.rs | UTF-8 | 2,690 | 2.609375 | 3 | [] | no_license | extern crate byteorder;
extern crate sdl2;
mod controller;
mod input;
mod network;
mod render;
mod world;
use byteorder::WriteBytesExt;
fn main() -> Result<(), String> {
let context = render::context::Context::init()?;
let mut window = context.create_window("Maze Maze", 800, 600)?;
let renderer = window.... | true |
fbbaf0bb6920cf2c6fb96da2a0b9b52d56e18010 | Rust | tylerztl/Bandot | /bandot-node/runtime/src/traits.rs | UTF-8 | 692 | 2.53125 | 3 | [
"Unlicense"
] | permissive | use rstd::result;
use rstd::fmt::Debug;
use sr_primitives::traits::{SimpleArithmetic, MaybeSerializeDeserialize};
use codec::FullCodec;
pub trait Token<AccountId> {
type Balance: SimpleArithmetic + FullCodec + Copy + MaybeSerializeDeserialize + Debug + Default;
fn total_supply() -> Self::Balance;
fn balance_of(who... | true |
af7523eb0de4031ca3e090c7e8441068396d65ab | Rust | dr4ds/resource-miner | /src/main.rs | UTF-8 | 6,531 | 2.65625 | 3 | [] | no_license | use bigint::U256;
use core::convert::TryFrom;
use rand::Rng;
use std::collections::HashMap;
use std::io::prelude::*;
use std::sync::{mpsc, Arc, Mutex};
use std::thread;
use std::time::SystemTime;
const CHUNK_SIZE: u32 = 50000;
type Nonce = u32;
type ResourceTarget = [u8; 32];
type Args = HashMap<String, String>;
#[d... | true |
9646076765ba845fae47bcc109e5c2db0092f8ba | Rust | HerringtonDarkholme/leetcode | /src/1202_smallest_string_with_swaps.rs | UTF-8 | 1,136 | 3.125 | 3 | [] | no_license | impl Solution {
pub fn smallest_string_with_swaps(s: String, pairs: Vec<Vec<i32>>) -> String {
let mut parents: Vec<_> = (0..s.len()).collect();
for pair in pairs {
union(&mut parents, pair[0] as usize, pair[1] as usize);
}
let mut groups = std::collections::HashMap::new(... | true |
3baa563e521b883c9c02d7fb9266cc01a9644185 | Rust | INDAPlus20/isaklar-ahanifi-maltebl-lervik-project | /pphysx3d/examples/demo.rs | UTF-8 | 3,235 | 2.828125 | 3 | [] | no_license | extern crate pphysx3d;
use pphysx3d::{
renderer::{Kiss3dRenderer, Renderer},
scene::{
game_object::{GameObject, INFINITY},
PhysicsScene,
},
};
fn main() {
//Initialize renderer & scene
let mut renderer = Kiss3dRenderer::new("Demo", 1200, 900);
let mut scene = Physics... | true |
eda9a840c7f13b424e6a6e9e405a4b9100bc7d07 | Rust | Christopher22/matryoshka-sqlite | /bindings/tests/interface.rs | UTF-8 | 3,627 | 2.671875 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use std::ffi::CString;
use std::io::{Read, Write};
use std::ptr::null_mut;
use matryoshka::Status;
use test_case::test_case;
#[test]
fn test_loading() {
let database_path = CString::new(":memory:").expect("Valid database path");
let mut status: *mut Status = null_mut();
let file_system = unsafe { matryosh... | true |
a3201aeffa7d330fd493772f895c3c6f7a2322e2 | Rust | INDAPlus20/faband-chess | /src/piece/piece_types.rs | UTF-8 | 214 | 3.015625 | 3 | [] | no_license | #[derive(Copy, Clone, Debug, PartialEq)]
///All types pieces that exist on the board (listed in order of value in my opinion)
pub enum PieceType {
Pawn,
Knight,
Bishop,
Rook,
Queen,
King,
}
| true |
fb8e6fe5ae7a18df6dc3cf5f0dab80885296a969 | Rust | benbrunton/pusoy_dos_server | /project/src/controller/about.rs | UTF-8 | 1,237 | 2.875 | 3 | [] | no_license | use tera::{Tera, Context, Result as TeraResult};
use std::panic::RefUnwindSafe;
use controller::{Controller, ResponseType};
use model::Session;
use helpers::{PathExtractor, QueryStringExtractor};
#[derive(Clone)]
pub struct AboutController {
tera: &'static Tera
}
impl AboutController {
pub fn new(tera: &'sta... | true |
78133fc4107e83b6e7139195795577c945a3502a | Rust | jesskfullwood/openapiv3 | /src/components.rs | UTF-8 | 2,079 | 2.796875 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use crate::*;
use serde::{Deserialize, Serialize};
use std::collections::BTreeMap;
/// Holds a set of reusable objects for different aspects of the OAS.
/// All objects defined within the components object will have no effect
/// on the API unless they are explicitly referenced from properties
/// outside the componen... | true |
c2552987a6d8a46d0dd5558aa36dc212f3c243dd | Rust | Zengor/parallelized-acotsp | /src/logger.rs | UTF-8 | 971 | 2.515625 | 3 | [] | no_license | use std::time;
use log::info;
use itertools::Itertools;
use crate::aco::AntResult;
pub enum OutputType {
StdOut,
File(String),
StdAndFile(String)
}
pub fn setup_logger(output: OutputType) -> Result<(), fern::InitError> {
let f = fern::Dispatch::new()
.format(|out, message, record| {
... | true |
1da46cb9a4d64198daed8f8b4e7981a951ea942e | Rust | gnoliyil/fuchsia | /src/settings/service/src/monitor/base.rs | UTF-8 | 1,763 | 2.59375 | 3 | [
"BSD-2-Clause"
] | permissive | // Copyright 2020 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//! Base definitions for working with monitors and outlets.
use std::borrow::Cow;
#[derive(thiserror::Error, Debug, Clone, PartialEq)]
pub enum Error {
... | true |
d667225da6b250f1a10b70f577c7905ed574606f | Rust | dovahcrow/okex-rs | /src/rest/models/trade/order.rs | UTF-8 | 4,472 | 2.5625 | 3 | [] | no_license | use super::super::Request;
use crate::enums::{InstType, OrdState, OrdType, PosSide, Side, TdMode};
use crate::parser::ts_milliseconds;
use chrono::{DateTime, Utc};
use http::Method;
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct PlaceO... | true |
35421ecbce4aed86b8da195339b2bb550cc8bb73 | Rust | TheTriumvirate/brainstorm | /brainstorm/src/camera/arcball.rs | UTF-8 | 4,306 | 3.046875 | 3 | [
"MIT"
] | permissive | use crate::camera::Camera;
use na::{Isometry3, Matrix4, Perspective3, Point3, Vector2, Vector3};
use std::f32;
use window::{Event, MouseButton};
/// A camera that orbits around a point in space.
pub struct ArcBall {
target: Point3<f32>,
yaw: f32,
pitch: f32,
distance: f32,
projection: Matrix4<f32>,... | true |
1be03f18c1acaf38b0051298b3cc79bb9c292947 | Rust | technocreatives/artefacta | /src/index/build.rs | UTF-8 | 1,184 | 3.265625 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use crate::{index::Version, storage::Entry};
/// Artefact with version
#[derive(Debug, Clone, Eq, PartialOrd, Ord)]
pub struct Build {
pub(crate) version: Version,
pub(crate) local: Option<Entry>,
pub(crate) remote: Option<Entry>,
}
/// Builder
///
/// Sup dawg i herd u liked builds so I put a builder pat... | true |
782e999bec9d4fe8b8dd682e636d2e01e72be518 | Rust | kimsk/try-rust | /karlkim/ownership/src/main.rs | UTF-8 | 906 | 3.71875 | 4 | [] | no_license | fn main() {
give();
lender();
use_push_all();
}
fn give() {
let mut vec = Vec::new();
vec.push(1);
vec.push(2);
take(vec);
//vec.push(3);
}
fn take(vec: Vec<i32>) {
println!("{:?}", vec);
}
fn lender() {
let mut vec = Vec::new();
vec.push(1);
vec.push(2);
use_vecto... | true |
68befda2852f700d4984af05be84cd623c886594 | Rust | andreasots/motd-generator | /src/loadavg.rs | UTF-8 | 787 | 2.625 | 3 | [
"Apache-2.0"
] | permissive | use regex::Regex;
use std::error::Error;
use std::io::Read;
use std::fs::File;
pub fn loadavg() -> Result<(f32, f32, f32), Box<Error>> {
let mut line = String::new();
try!(try!(File::open("/proc/loadavg")).read_to_string(&mut line));
let regex = try!(Regex::new(r"^(\d+\.\d+) (\d+\.\d+) (\d+\.\d+) (\d+)/(\d... | true |
a8ff5350634b3cfd522926f4ca6a6b12bc4fd49e | Rust | hrektts/piece-of-code | /hackerrank/algorithms/greedy/marcs-cakewalk/src/main.rs | UTF-8 | 481 | 2.875 | 3 | [] | no_license | use std::io::{self, BufRead};
fn main() {
let io = io::stdin();
let mut lines = io.lock().lines().filter_map(|s| s.ok());
let mut cs = lines
.nth(1)
.unwrap()
.trim()
.split(' ')
.map(|s| s.parse::<usize>().ok().unwrap())
.collect::<Vec<_>>();
cs.sort_b... | true |
726172f7d8b37afd63879420ce34ad92379564d0 | Rust | tmfink/yinetd | /src/config/mod.rs | UTF-8 | 845 | 2.890625 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use std::collections::HashSet;
use log::debug;
use crate::service::Service;
mod config_types;
pub mod parse;
pub use config_types::*;
#[derive(Debug, Default)]
pub struct Config {
services: Vec<Service>,
service_names: HashSet<String>,
}
impl Config {
pub fn new() -> Self {
Default::default()
... | true |
0e4255c6da620db5096719d6456660232832e142 | Rust | rust-lang/glacier | /ices/102047.rs | UTF-8 | 718 | 2.765625 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | struct Ty1;
struct Ty2;
pub trait Trait<T> {}
pub trait WithAssoc1<'a> {
type Assoc;
}
pub trait WithAssoc2<'a> {
type Assoc;
}
impl<T, U> Trait<for<'a> fn(<T as WithAssoc1<'a>>::Assoc, <U as WithAssoc2<'a>>::Assoc)> for (T, U)
where
T: for<'a> WithAssoc1<'a> + for<'a> WithAssoc2<'a, Assoc = i32>,
U:... | true |
738626712c17c612c14b3fed5b1361472bde59f2 | Rust | phial3/rustos-hdmi | /lib/pi/src/mbox2.rs | UTF-8 | 1,771 | 2.9375 | 3 | [] | no_license | use volatile::prelude::*;
use volatile::{ReadVolatile, Reserved, Volatile, WriteVolatile};
use core::time::Duration;
use core::cmp::min;
use crate::common::MBOX_BASE;
use crate::timer::spin_sleep;
#[repr(C)]
pub struct Message { msg: u32 }
impl Message {
pub fn new(channel: u8, data: u32) -> Message {
M... | true |
e708efdb61bf8859ca09c4aef38c7d22f21a6919 | Rust | PriyanshuDas/ProjectEuler | /src/problems/problem_51.rs | UTF-8 | 3,689 | 3.296875 | 3 | [] | no_license | use crate::helper_modules::prime_generator;
use crate::helper_modules::digits_extractor;
use crate::helper_modules::combination_vector_generator;
/*
Find the smallest prime which by replacing part of the number with the same digit,
is part of an eight prime value family
*/
const DEBUG_ENABLED: bool = false;
f... | true |
49128fcf56076656e6f19f5eb7760d822e9636b2 | Rust | hyperchessbot/replit | /adventofcode/20201206/rust/puzzle.rs | UTF-8 | 812 | 2.90625 | 3 | [] | no_license | use std::collections::HashSet;
fn main() {
let records = std::fs::read_to_string("../input.txt").unwrap();
let records = records.split("\n\n").map(|group| {
group
.split('\n')
.map(|person| person.chars().collect::<HashSet<char>>())
});
let mut output = 0usize;
let ... | true |
eaff11265a86a4dcd1d59cb4c6d812536a297915 | Rust | scifi6546/gameboy_emulator | /gameboy_core/src/mmu/mbc2.rs | UTF-8 | 2,719 | 2.984375 | 3 | [
"Apache-2.0"
] | permissive | use super::cartridge::Cartridge;
use super::mbc::Mbc;
pub struct Mbc2 {
cartridge: Cartridge,
selected_rom_bank: usize,
external_ram_enabled: bool,
ram_change_callback: Box<dyn FnMut(usize, u8)>,
}
impl Mbc for Mbc2 {
fn read_byte(&self, index: u16) -> u8 {
match index {
0x0000... | true |
1b80e3601fc7e67ad008c6945691f206c42d834e | Rust | CarlEkerot/gameboy | /src/emulator.rs | UTF-8 | 1,772 | 3.0625 | 3 | [] | no_license | use constants::*;
use cpu::CPU;
use timer::Timer;
use std::fs::File;
use memory::Memory;
use std::time::SystemTime;
use std::time::Duration;
use std::thread;
use std::rc::Rc;
use std::cell::RefCell;
pub struct Emulator<'a> {
cpu: CPU,
timer: Timer,
pub rom: &'a File,
}
impl<'a> Emulator<'a> {
pub fn n... | true |
1f00980e39d02135fd26bd3252ada008a849ffc2 | Rust | wgreenberg/rs-git | /src/blob.rs | UTF-8 | 888 | 3.046875 | 3 | [] | no_license | use failure::{Error};
use crypto::digest::Digest;
use crypto::sha1::Sha1;
use std::path::{PathBuf};
use std::fs;
use std::io::Read;
pub struct Blob {
pub data: Vec<u8>,
pub size: usize,
pub oid: String,
}
impl Blob {
pub fn new_from_path(path: &PathBuf) -> Result<Blob, Error> {
let mut blob = ... | true |
eb3586a882578d3e9901d4230372a821fa07bdc3 | Rust | wotsushi/competitive-programming | /etc/aising2019/b.rs | UTF-8 | 1,030 | 2.828125 | 3 | [
"MIT"
] | permissive | #![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]
fn main() {
let N: usize = {
let mut line: String = String::new();
std::io::stdin().read_line(&mut line).unwrap();
line.trim().parse().unwrap()
};
let (A, B): (i64, i64) = {
let mut line: String = Str... | true |
c423e02dfd4e48c73c32b9fbbc914ed4a14b35f7 | Rust | coreywkruger/rustd | /src/entities/vector3d.rs | UTF-8 | 5,419 | 3.640625 | 4 | [] | no_license | use std::f64::{consts};
// #[derive(Debug, Copy, Clone)]
pub struct Vector3d {
pub x: f64,
pub y: f64,
pub z: f64
}
// impl Copy for Vector3d {}
// impl Clone for Vector3d {
// fn clone(&self) -> Vector3d { *self }
// }
// impl Clone for Vector3d {}
impl Vector3d {
pub fn new(x: f64, y: f64, z: f64) -> Vecto... | true |
a9c95ffa3ceebdf160b590a9619f3ef8c34f1d19 | Rust | mikelodder7/celes | /tests/country.rs | UTF-8 | 1,374 | 2.8125 | 3 | [
"Apache-2.0"
] | permissive | use celes::{Country, LookupTable};
use std::str::FromStr;
#[test]
fn from_strings() {
for c in &Country::get_countries() {
let res = Country::from_str(&c.to_string());
assert!(res.is_ok());
assert_eq!(res.unwrap(), *c);
let res = Country::from_name(&c.to_string());
assert!(... | true |
c0a965ca883b1c994107b29dfdbd11e0f7e6a3be | Rust | hanhossain/advent-of-code | /rust/src/year2019/vm.rs | UTF-8 | 13,785 | 3.6875 | 4 | [
"MIT"
] | permissive | use std::fmt::{Debug, Error, Formatter};
use std::io;
pub struct Intcode<'a> {
memory: &'a mut [i32],
instruction_pointer: usize,
}
impl<'a> Intcode<'a> {
pub fn new(memory: &'a mut [i32]) -> Self {
Intcode {
memory,
instruction_pointer: 0,
}
}
pub fn run(&... | true |
3165046099459c5771c8ab1be21483c33135b61f | Rust | svetli-n/shop-frontend | /src/pages/item_list.rs | UTF-8 | 7,147 | 2.9375 | 3 | [] | no_license | use crate::pages::item::Item;
use yew::{html, Component, ComponentLink, Html, Properties, InputData, Bridge};
use yew::{events::KeyboardEvent, Classes};
use std::collections::{HashMap, BTreeMap};
use yew::format::{Json, Nothing};
use anyhow::Error;
use yew::services::fetch::{FetchService, FetchTask, Request, Response};... | true |
1e75b0e2ec36e9894b527dcdfb0e1985de0bcc8c | Rust | 0xb10ckdev/forest | /src/cli/humantoken.rs | UTF-8 | 22,604 | 3.03125 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | // Copyright 2019-2023 ChainSafe Systems
// SPDX-License-Identifier: Apache-2.0, MIT
//! This module defines a [parser](parse()) and
//! [pretty-printer](TokenAmountPretty::pretty) for
//! `TokenAmount`
//!
//! See the `si` module source for supported prefixes.
pub use parse::parse;
pub use print::TokenAmountPretty;
... | true |
6daab8a2b39cafb522fd688e4f3ba4b01b6382cd | Rust | gyn/exercism | /rust/assembly-line/src/lib.rs | UTF-8 | 335 | 2.8125 | 3 | [
"BSD-2-Clause"
] | permissive | pub fn production_rate_per_hour(speed: u8) -> f64 {
let percentage = match speed {
1..=4 => 1.0,
5..=8 => 0.9,
9..=10 => 0.77,
_ => 0.0,
};
percentage * (221 * speed as u32) as f64
}
pub fn working_items_per_minute(speed: u8) -> u32 {
(production_rate_per_hour(speed) / ... | true |
955c6fa1059fcb4caa3ecaac4fb5081048093d59 | Rust | antiphoton/typescript-definitions | /tests/typescript.rs | UTF-8 | 10,037 | 2.765625 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | #![allow(unused)]
use typescript_definitions::{TypeScriptify, TypeScriptifyTrait, TypescriptDefinition};
use serde::Serialize;
use std::borrow::Cow;
// use serde::de::value::Error;
use insta::assert_snapshot_matches;
use wasm_bindgen::prelude::*;
#[cfg(feature = "test")]
#[test]
fn unit_struct() {
#[derive(Seri... | true |
c17416def57e52cef7bcf77b6bf688349ce4f251 | Rust | trembel/ambiq-apollo3p-pac | /src/iom0/mspicfg.rs | UTF-8 | 27,993 | 2.65625 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | #[doc = "Reader of register MSPICFG"]
pub type R = crate::R<u32, super::MSPICFG>;
#[doc = "Writer for register MSPICFG"]
pub type W = crate::W<u32, super::MSPICFG>;
#[doc = "Register MSPICFG `reset()`'s with value 0x0020_0000"]
impl crate::ResetValue for super::MSPICFG {
type Type = u32;
#[inline(always)]
f... | true |
448196fa1ea1e605e75cac3bed3bef60e1cb8ad9 | Rust | LaplaceKorea/newton_rootfinder | /src/solver_n_dimensional/solver/default.rs | UTF-8 | 3,553 | 2.796875 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use std::fmt;
use super::ResolutionMethod;
use super::RootFinder;
use super::SolverParameters;
use crate::iteratives::Iterative;
use crate::iteratives;
use crate::residuals;
/// Default function to create a solver with default parameters
///
/// The default parameters are:
/// - max_iter = 50
/// - tolerance = 1e-6
... | true |
a916ef7e7da512d140b817fac07a9da6e369d77f | Rust | msgpo/pH | /ph-init/src/error.rs | UTF-8 | 3,939 | 2.515625 | 3 | [] | no_license | use std::{result, io, fmt};
use crate::netlink;
pub enum Error {
Pid1,
KernelCmdLine(io::Error),
NoRootVar,
NoRootFsVar,
RootFsMount(String, io::Error),
MountProcFS(io::Error),
MountTmpFS(String, io::Error),
MountSysFS(io::Error),
MountCGroup(io::Error),
MountDevTmpFS(io::Error)... | true |
ce9f317a8ff780dbc513a14d4d1b77cc44521744 | Rust | relievedFace/competitive-programming-library | /src/matrix.rs | UTF-8 | 3,223 | 3.21875 | 3 | [
"MIT"
] | permissive | use itertools::{iproduct, Itertools};
use std::collections::HashSet;
pub fn rotate<T>(matrix: &Vec<Vec<T>>) -> Vec<Vec<T>>
where
T: Clone,
{
let rows = matrix.len();
let cols = matrix[0].len();
iproduct!(0..cols, (0..rows).rev())
.map(|(new_row, new_col)| matrix[new_col][new_row].clone())
... | true |
23084bb316d5e01709e9c4a27e496aa85a8225a2 | Rust | Pmyl/twitch-commands | /src/utils/run_on_stream.rs | UTF-8 | 1,934 | 3.296875 | 3 | [] | no_license | use futures::stream::{Stream};
use futures::{pin_mut, StreamExt as Ext};
use std::fmt::Display;
use tokio::sync::mpsc::{Sender};
pub trait StreamItemReceiver {
type Item;
type Output;
fn receive(&mut self, item: Self::Item) -> Self::Output;
}
pub enum StreamEvent<T> {
Item(T),
Stop
}
pub async fn... | true |
db1d71dd1b18a9ba61bf227f85328322fd43b455 | Rust | Yurihaia/nbtdoc-rs | /src/parse/ast.rs | UTF-8 | 2,954 | 2.5625 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use crate::identifier::Identifier;
use crate::validation::FieldPath;
#[derive(Debug, PartialEq)]
pub struct NbtDocFile {
pub uses: Vec<(bool, IdentPath)>,
pub compounds: Vec<(String, CompoundDef)>,
pub enums: Vec<(String, EnumDef)>,
pub describes: Vec<(IdentPath, DescribeDef)>,
pub mods: Vec<String... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.